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
Closed

Conversation

MarcelRaad
Copy link
Member

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

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this too

char * enodename;
char * eservname;
char * enodename = (char *)NULL;
char * eservname = (char *)NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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
Unused since commit 2f44e94.

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

Closes curl#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 curl#3975
Compilers and static analyzers warn about using C-style casts here.

Closes curl#3975
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 codacy_again branch September 30, 2019 21:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

None yet

3 participants