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 some cppcheck warnings #816

Merged
merged 1 commit into from
May 20, 2023
Merged

fix some cppcheck warnings #816

merged 1 commit into from
May 20, 2023

Conversation

alfredh
Copy link
Contributor

@alfredh alfredh commented May 20, 2023

Command:

$ cppcheck -q -f --std=c99 --enable=warning .

Command:

$ cppcheck -q -f --std=c99 --enable=warning .
@sreimers sreimers merged commit d1cf923 into main May 20, 2023
@sreimers sreimers deleted the cppcheck_fixes branch May 20, 2023 10:00
@alfredh
Copy link
Contributor Author

alfredh commented May 20, 2023

after this commit there are some warnings left:

Alfreds-MacBook-Pro-M1:re alfredh$ ~/bin/cppcheck.sh 
src/base64/b64.c:86:29: warning: Either the condition '!in' is redundant or there is pointer arithmetic with NULL pointer. [nullPointerArithmeticRedundantCheck]
 const uint8_t *in_end = in + ilen;
                            ^
src/base64/b64.c:89:6: note: Assuming that condition '!in' is not redundant
 if (!in || !out || !olen)
     ^
src/base64/b64.c:86:29: note: Null pointer addition
 const uint8_t *in_end = in + ilen;
                            ^
src/base64/b64.c:188:26: warning: Either the condition '!in' is redundant or there is pointer arithmetic with NULL pointer. [nullPointerArithmeticRedundantCheck]
 const char *in_end = in + ilen;
                         ^
src/base64/b64.c:191:6: note: Assuming that condition '!in' is not redundant
 if (!in || !out || !olen)
     ^
src/base64/b64.c:188:26: note: Null pointer addition
 const char *in_end = in + ilen;
                         ^
src/http/client.c:571:36: warning: Either the condition '!req->cli' is redundant or there is possible null pointer dereference: req->cli. [nullPointerRedundantCheck]
 conn = list_ledata(hash_lookup(req->cli->ht_conn,
                                   ^
src/http/client.c:574:7: note: Assuming that condition '!req->cli' is not redundant
  if (!req->cli)
      ^
src/http/client.c:571:36: note: Null pointer dereference
 conn = list_ledata(hash_lookup(req->cli->ht_conn,
                                   ^
src/sipevent/sipevent.h:51:39: error: syntax error [syntaxError]
void sipnot_refresh(struct sipnot *not, uint32_t expires);
                                      ^
src/tls/openssl/tls.h:32:1: error: There is an unknown macro here somewhere. Configuration is required. If STACK_OF is a macro then please configure it. [unknownMacro]
STACK_OF(X509*) tls_cert_chain(struct tls_cert *hc);
^
test/ice.c:295:9: warning: Identical condition and return expression 'err', return value is always 0 [identicalConditionAfterEarlyExit]
 return err;
        ^
test/ice.c:291:6: note: If condition 'err' is true, the function will return/exit
 if (err)
     ^
test/ice.c:295:9: note: Returning identical expression 'err'
 return err;
        ^
test/rtp.c:424:9: warning: Identical condition and return expression 'err', return value is always 0 [identicalConditionAfterEarlyExit]
 return err;
        ^
test/rtp.c:417:6: note: If condition 'err' is true, the function will return/exit
 if (err)
     ^
test/rtp.c:424:9: note: Returning identical expression 'err'
 return err;
        ^

@sreimers
Copy link
Member

sreimers commented May 20, 2023

I get some better results with:

$ cppcheck -q --project=build/compile_commands.json 
src/sipevent/sipevent.h:51:39: error: syntax error [syntaxError]
void sipnot_refresh(struct sipnot *not, uint32_t expires);
                                      ^
src/sipsess/connect.c:297:52: error: Uninitialized struct member: hdrs.l [uninitStructMember]
 sess->rel100_supported = fmt && !re_regex(hdrs.p, hdrs.l, "100rel");
                                                   ^
src/tls/openssl/tls.h:32:1: error: There is an unknown macro here somewhere. Configuration is required. If STACK_OF is a macro then please configure it. [unknownMacro]
STACK_OF(X509*) tls_cert_chain(struct tls_cert *hc);
^

Cppcheck 2.10.3

@sreimers
Copy link
Member

Ah I see "--warning" enables a lot more, but I think we should maybe fix first without warning option.

@alfredh
Copy link
Contributor Author

alfredh commented May 20, 2023


Alfreds-MacBook-Pro-M1:re alfredh$ cppcheck --version
Cppcheck 2.10.3
Alfreds-MacBook-Pro-M1:re alfredh$ cppcheck -q -f --std=c99 .
src/sipevent/sipevent.h:51:39: error: syntax error [syntaxError]
void sipnot_refresh(struct sipnot *not, uint32_t expires);
                                      ^
src/tls/openssl/tls.h:32:1: error: There is an unknown macro here somewhere. Configuration is required. If STACK_OF is a macro then please configure it. [unknownMacro]
STACK_OF(X509*) tls_cert_chain(struct tls_cert *hc);
^


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants