Hi, I'm having what appears to be a false positive, compiling this section, where it goes through two elements of a linked-list :
msg = msg->next; if (msg == NULL) { return CMD_OK; } msg = msg->next; if (msg == NULL) { return CMD_OK; }
(complete file: https://github.com/fenugrec/freediag/blob/master/scantool/scantool_850.c#L1240 )
cppcheck complains about that :
scantool/scantool_850.c:1241:10: style: Condition 'msg==NULL' is always false [knownConditionTrueFalse] if (msg == NULL) { ^ scantool/scantool_850.c:1233:10: note: Assuming that condition 'msg==NULL' is not redundant if (msg == NULL) { ^ scantool/scantool_850.c:1232:6: note: msg is assigned 'msg->next' here. msg = msg->next; ^ scantool/scantool_850.c:1233:10: note: Assuming condition is false if (msg == NULL) { ^ scantool/scantool_850.c:1240:11: note: Assignment 'msg=msg->next', assigned value is never 0 msg = msg->next; ^ scantool/scantool_850.c:1241:10: note: Condition 'msg==NULL' is always false if (msg == NULL) {
Of course the issue is "msg->next" means something different the second time, and can be 0, but cppcheck fails to recognize this ?
Thanks! I can reproduce. I have created https://trac.cppcheck.net/ticket/10649
Wow that was fast. Thanks a lot for your work on cppcheck, it's very useful even with occasional issues like this one.
Log in to post a comment.
Hi,
I'm having what appears to be a false positive, compiling this section, where it goes through two elements of a linked-list :
(complete file: https://github.com/fenugrec/freediag/blob/master/scantool/scantool_850.c#L1240 )
cppcheck complains about that :
Of course the issue is "msg->next" means something different the second time, and can be 0, but cppcheck fails to recognize this ?
Thanks! I can reproduce. I have created https://trac.cppcheck.net/ticket/10649
Wow that was fast. Thanks a lot for your work on cppcheck, it's very useful even with occasional issues like this one.