User Activity

  • Posted a comment on discussion General Discussion on cppcheck

    With --enable=all 2.12.0, 2.12.1 and current git (6773cdb34bb4697a41c4438ebb2a34c4e4de4b69) all report knownConditionTrueFalse on the following code: #define MIN(x, y) (((x) < (y)) ? (x) : (y)) void example(unsigned int old_val) { unsigned int new_val = MIN(old_val, 65535); if (!new_val) { } } This is clearly incorrect. $ ~/src/cppcheck/cppcheck --enable=all example.c Checking example.c ... example.c:7:6: style: Condition '!new_val' is always true [knownConditionTrueFalse] if (!new_val) { ^ example.c:5:25:...

  • Posted a comment on discussion General Discussion on cppcheck

    Wow, that was fast. Thanks!

  • Posted a comment on discussion General Discussion on cppcheck

    sizeof(*foo) doesn't actually dereference foo, and so shouldn't generate a NULL pointer dereference warning. However, cppcheck will do so under at least some circumstances. For example: #include <stdio.h> struct foo { int a; char b; }; static void func(struct foo *foo) { size_t len = sizeof(*foo); printf("%zd\n", len); } void func2(void) { func(NULL); } $ cppcheck ~/tmp/foo.c Checking /home/dwg/tmp/foo.c ... /home/dwg/tmp/foo.c:10:23: error: Null pointer dereference: foo [ctunullpointer] size_t len...

View All

Personal Data

Username:
dgibson
Joined:
2000-05-05 06:00:47

Projects

This is a list of open source software projects that David Gibson is associated with:

Personal Tools