Skip to content

Tidy: if with identical then and else branches #58596

@MaJerle

Description

@MaJerle

This is the code:

    if (!(b->flags & MY_FLAG)) {
        if ((mstime - b->time_change) >= GET_MIN(b)) {
            b->flags |= MY_FLAG;
            lw->evt_fn(lw, b, OPR);
            b->ka.last_time = mstime;
        }
    } else {
        if ((mstime - b->ka.last_time) >= PERIOD(b)) {
            b->ka.last_time += PERIOD(b);
            ++b->ka.cnt;
            lw->evt_fn(lw, b, OPS);
        }
    }

For which clang-tidy 15.0.0-rc3 throws an error: warning: if with identical then and else branches [bugprone-branch-clone]
Command is called as: clang-tidy -checks='*' file.c

How can this be same if and else branch?

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions