Visitar URL original
LGTM.com - false positive: constant-comparison with assignment on one side · Issue #3496 · github/codeql · GitHub
The Wayback Machine - https://web.archive.org/web/20260602130711/https://github.com/github/codeql/issues/3496
Skip to content

LGTM.com - false positive: constant-comparison with assignment on one side #3496

@wojdyr

Description

@wojdyr

I have

int next_char;
...
(next_char = gzgetc(file_)) != -1

where gzgetc is from zlib:

ZEXTERN int ZEXPORT gzgetc OF((gzFile file));

It triggers constant-comparison rule with message:

Comparison is always true because ... = ... >= 0.

In this case (a = b) is integer assignment and can be negative.

https://lgtm.com/projects/g/project-gemmi/gemmi/snapshot/d1a210cf4810719b905806a690feade01e6eb5c9/files/include/gemmi/gz.hpp?sort=name&dir=ASC&mode=heatmap#x4ec8a4d86c53b859:1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions