Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more Codacy warnings #3975

Closed
wants to merge 4 commits into from

Conversation

@MarcelRaad
Copy link
Member

MarcelRaad commented Jun 1, 2019

This brings the "code style" C warnings in Codacy down to 57, most of which are either false positives or dead stores with the variable overriden after being initialized to a default value.

I'm not going to merge this before the 7.65.1 release. Just opening the PR because I had already forgotten about that branch.

  • remove unused code
  • remove dead variable stores
  • reduce variable scopes
  • use C++ casts in C++ code
  • fix check if result of unsigned integer expression is negative
@MarcelRaad MarcelRaad added the tidy-up label Jun 1, 2019
@bagder
bagder approved these changes Jun 2, 2019
lib/ftp.c Outdated
/* We've sent the TYPE, now we must send the list of prequote strings */

result = ftp_state_quote(conn, TRUE, FTP_RETR_PREQUOTE);
CURLcode result = ftp_state_quote(conn, TRUE, FTP_RETR_PREQUOTE);

This comment has been minimized.

Copy link
@bagder

bagder Jun 2, 2019

Member

This could even do a return straight away without storing the return code in a variable...

lib/ftp.c Outdated
/* We've sent the TYPE, now we must send the list of prequote strings */

result = ftp_state_quote(conn, TRUE, FTP_STOR_PREQUOTE);
CURLcode result = ftp_state_quote(conn, TRUE, FTP_STOR_PREQUOTE);

This comment has been minimized.

Copy link
@bagder

bagder Jun 2, 2019

Member

this too

char * enodename;
char * eservname;
char * enodename = (char *)NULL;
char * eservname = (char *)NULL;

This comment has been minimized.

Copy link
@bagder

bagder Jun 2, 2019

Member

this could also fix the code style: make it char *ennodename (without the extra space after the asterisk)

This comment has been minimized.

Copy link
@captain-caveman2k

captain-caveman2k Jun 2, 2019

Member

Is this (char *) cast required for Codacy as we have char *variable = NULL elsewhere?

This comment has been minimized.

Copy link
@MarcelRaad

MarcelRaad Jun 2, 2019

Author Member

@captain-caveman2k No it's not, I just moved the whole expression from below. I'll remove the cast.

@MarcelRaad MarcelRaad force-pushed the MarcelRaad:codacy_again branch from dd257d4 to 5c46c2a Jun 2, 2019
MarcelRaad added a commit to MarcelRaad/curl that referenced this pull request Jun 2, 2019
Unused since commit 2f44e94.

Closes curl#3975
MarcelRaad added a commit to MarcelRaad/curl that referenced this pull request Jun 2, 2019
Reduce variable scopes and remove redundant variable stores.

Closes curl#3975
MarcelRaad added a commit to MarcelRaad/curl that referenced this pull request Jun 2, 2019
As want is size_t, (file->buffer_pos - want) is unsigned, so checking
if it's less than zero makes no sense.
Check if file->buffer_pos is less than want instead to avoid the
unsigned integer wraparound.

Closes curl#3975
MarcelRaad added a commit to MarcelRaad/curl that referenced this pull request Jun 2, 2019
Compilers and static analyzers warn about using C-style casts here.

Closes curl#3975
MarcelRaad added 4 commits May 25, 2019
Unused since commit 2f44e94.

Closes #3975
Reduce variable scopes and remove redundant variable stores.

Closes #3975
As want is size_t, (file->buffer_pos - want) is unsigned, so checking
if it's less than zero makes no sense.
Check if file->buffer_pos is less than want instead to avoid the
unsigned integer wraparound.

Closes #3975
Compilers and static analyzers warn about using C-style casts here.

Closes #3975
@MarcelRaad MarcelRaad force-pushed the MarcelRaad:codacy_again branch from 5c46c2a to 4c4a20f Jun 3, 2019
MarcelRaad added a commit to MarcelRaad/curl that referenced this pull request Jun 5, 2019
Reduce variable scopes and remove redundant variable stores.

Closes curl#3975
MarcelRaad added a commit to MarcelRaad/curl that referenced this pull request Jun 5, 2019
As want is size_t, (file->buffer_pos - want) is unsigned, so checking
if it's less than zero makes no sense.
Check if file->buffer_pos is less than want instead to avoid the
unsigned integer wraparound.

Closes curl#3975
MarcelRaad added a commit to MarcelRaad/curl that referenced this pull request Jun 5, 2019
Compilers and static analyzers warn about using C-style casts here.

Closes curl#3975
@MarcelRaad MarcelRaad closed this in 04ac54e Jun 5, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Sep 3, 2019
@MarcelRaad MarcelRaad deleted the MarcelRaad:codacy_again branch Sep 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.