Skip to content

Remove dead code in val2memstr: MAXEBYTE8 equals LLONG_MAX - #391

Open
natoscott wants to merge 1 commit into
Atoptool:masterfrom
natoscott:fix/coverity-deadcode-val2memstr
Open

Remove dead code in val2memstr: MAXEBYTE8 equals LLONG_MAX#391
natoscott wants to merge 1 commit into
Atoptool:masterfrom
natoscott:fix/coverity-deadcode-val2memstr

Conversation

@natoscott

Copy link
Copy Markdown
Contributor

MAXEBYTE8 is defined as (ONEEBYTE*7 + (ONEEBYTE-1)) which evaluates to 9223372036854775807 — exactly LLONG_MAX. Since count_t is signed long long, the check "verifyval <= MAXEBYTE8" is always true, making the OVFORMAT branch unreachable dead code.

Simplify: anything past MAXPBYTE is unconditionally EBFORMAT. Remove the unused MAXEBYTE8, MAXEBYTE, EBFORMAT_INT and OVFORMAT symbols.

Found by Coverity Scan (CID 504429, CID 504430).

MAXEBYTE8 is defined as (ONEEBYTE*7 + (ONEEBYTE-1)) which evaluates
to 9223372036854775807 — exactly LLONG_MAX.  Since count_t is signed
long long, the check "verifyval <= MAXEBYTE8" is always true, making
the OVFORMAT branch unreachable dead code.

Simplify: anything past MAXPBYTE is unconditionally EBFORMAT.  Remove
the unused MAXEBYTE8, MAXEBYTE, EBFORMAT_INT and OVFORMAT symbols.

Found by Coverity Scan (CID 504429, CID 504430).
@GermanAizek

Copy link
Copy Markdown
Contributor

@natoscott,
I am glad that you are engaged not only in Htop, but also in Atop. It's nice to see people who participate in different projects, performing almost the same functions, but giving users the opportunity to choose freely.

@natoscott

Copy link
Copy Markdown
Contributor Author

@GermanAizek thank you for the kind words - it's nice to see you here too!

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