Skip to content

umash_long.inc: mark dead assignments as expected#38

Merged
pkhuong merged 1 commit intomasterfrom
pkhuong/clang-analyzer
Aug 24, 2025
Merged

umash_long.inc: mark dead assignments as expected#38
pkhuong merged 1 commit intomasterfrom
pkhuong/clang-analyzer

Conversation

@pkhuong
Copy link
Copy Markdown
Collaborator

@pkhuong pkhuong commented Aug 24, 2025

It's more important to remember to always advance the reader cursor after reading bytes than it is to avoid dead code that's trivially eliminated by the compiler.

Fixes #37

It's more important to remember to always advance the reader cursor
after reading bytes than it is to avoid dead code that's trivially
eliminated by the compiler.
@pkhuong
Copy link
Copy Markdown
Collaborator Author

pkhuong commented Aug 24, 2025

Before:

umash$ scan-build clang-20 -march=native+crypto -O3 -c umash.c
scan-build: Using '/usr/bin/clang-20' for static analysis
In file included from umash.c:521:
./umash_long.inc:576:4: warning: Value stored to 'data' is never read [deadcode.DeadStores]
  576 |                         data = (const char *)data + sizeof(y);
      |                         ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

After:

umash$ scan-build clang-20 -march=native+crypto -O3 -c umash.c
scan-build: Using '/usr/bin/clang-20' for static analysis
scan-build: Analysis run complete.
scan-build: Removing directory '/tmp/scan-build-2025-08-24-120201-300959-1' because it contains no reports.
scan-build: No bugs found.

@pkhuong pkhuong merged commit bb67b9e into master Aug 24, 2025
8 of 16 checks passed
@pkhuong pkhuong deleted the pkhuong/clang-analyzer branch August 24, 2025 17:00
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.

Dead code identified by clang --analyze

1 participant