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

Cppcheck: Uninitialized variable warning #229

Open
gg21-aping opened this issue Mar 5, 2025 · 1 comment
Open

Cppcheck: Uninitialized variable warning #229

gg21-aping opened this issue Mar 5, 2025 · 1 comment

Comments

@gg21-aping
Copy link
Contributor

gg21-aping commented Mar 5, 2025

Commit e0c6b11 has suppressed cppcheck "unused label" warnings by having entry = (void *) 1.

However, if we did not declare safe as NULL or anything else (which is not necessary in linux kernel, where we declare variables at the beginning of block), cppcheck still considers safe as an uninitialized variable. Thus, the commit still cannot be made unless we initialize the variable first.

The original commit set both entry and safe to (void *) 1,

#define list_for_each_entry_safe(entry, safe, head, member)       \
    for (entry = safe = (void *) 1; sizeof(struct { int : -1; }); \
    (...)

while the merged commit to master neglect safe.

#define list_for_each_entry_safe(entry, safe, head, member)  \
    for (entry = (void *) 1; sizeof(struct { int i : -1; }); \
    (...)

Wondering if it is necessary to make the change.

@jserv
Copy link
Contributor

jserv commented Mar 5, 2025

I defer to @lumynou5 .

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

No branches or pull requests

2 participants