Skip to content

Cppcheck: Uninitialized variable warning #229

Closed
@gg21-aping

Description

@gg21-aping

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions