Skip to content

Fix #15113 FP nullPointer with pthread functions - #8946

Open
chrchr-github wants to merge 4 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_15113
Open

chrchr-github wants to merge 4 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_15113

Conversation

@chrchr-github

Copy link
Copy Markdown
Collaborator

No description provided.

@chrchr-github
chrchr-github marked this pull request as ready for review October 16, 2026 13:15

@dmcppcheck dmcppcheck left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

AI review

I found no problems. Removing <not-null/> from argument 2 of pthread_cond_init and argument 2 of pthread_cleanup_push matches POSIX: a NULL attr means the default attributes, and arg is passed unchanged to the cleanup routine. <not-uninit/> is kept, so an uninitialised argument is still reported for both. Other functions that accept NULL, such as pthread_mutex_init and pthread_create, already allow it in the config, so the change matches them. The new tests in test/cfg/posix.c cover the NULL case and the uninitialised case.

Testing

  • I built cppcheck from pr/. I did not build testrunner because this PR changes only cfg/ and test/cfg/.
  • I ran the library test on test/cfg/posix.c with the options from test/cfg/runtests.sh (--check-library --check-level=exhaustive --enable=style,information --inconclusive --inline-suppr --debug-warnings --library=posix). It reported nothing, so there were no unmatched suppressions and no unexpected warnings.
  • I compared the old and new config on a scratch file. I ran the PR's binary on it twice, once with --library=/tmp/baseposix.cfg (a copy of the base posix.cfg) and once with --library=posix:
#include <pthread.h>
void f(pthread_cond_t *c, void (*r)(void*)) {
    pthread_cond_init(c, NULL);
    pthread_cleanup_push(r, NULL);
    pthread_cleanup_pop(0);
    pthread_cond_t c2;
    pthread_cond_init(&c2, 0);
    pthread_condattr_t *a;
    pthread_cond_init(&c2, a);
    void *p;
    pthread_cleanup_push(r, p);
    pthread_cleanup_pop(1);
}
  • Base config: 3 nullPointer false positives (lines 3, 4 and 7) and 2 uninitvar (lines 9 and 11).
  • PR config: only the 2 correct uninitvar warnings (lines 9 and 11).

Automated review of a76d465 by Claude. The pull request was built and tested locally.

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