Cppcheck 2.7
'num' is never the divider in this code yet a division by zero due to num is deemed possible because of the test for '!num'.
Called with cppcheck --inline-suppr --enable=all --inconclusive --suppress=unusedFunction -Duint8=unsigned '-Dxuint8=unsigned char' -Duint16=unsigned '-Dxuint16=unsigned short' ./tmp.c
cppcheck --inline-suppr --enable=all --inconclusive --suppress=unusedFunction -Duint8=unsigned '-Dxuint8=unsigned char' -Duint16=unsigned '-Dxuint16=unsigned short' ./tmp.c
tmp.c:5:13: warning: Either the condition '!num' is redundant or there is division by zero at line 5. [zerodivcond] c = num % radix; ^ tmp.c:7:10: note: Assuming that condition '!num' is not redundant if ( !num ) ^ tmp.c:6:12: note: Assignment to 'num/=radix' num /= radix; ^ tmp.c:5:13: note: Division by zero c =
void tmp(uint16 num, uint8 radix) { for ( i=0; i<5; i++) { c = num % radix; // Isolate a digit num /= radix; if ( !num ) break; } }
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11505
Log in to post a comment.
Cppcheck 2.7
'num' is never the divider in this code yet a division by zero due to num is deemed possible because of the test for '!num'.
Called with
cppcheck --inline-suppr --enable=all --inconclusive --suppress=unusedFunction -Duint8=unsigned '-Dxuint8=unsigned char' -Duint16=unsigned '-Dxuint16=unsigned short' ./tmp.c
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11505