Skip to content

Fix clang-tidy 14 findings in test.c, sha3.c and aes.c - #11970

Merged
douzzer merged 1 commit into
wolfSSL:masterfrom
Frauschi:fix-clang-tidy-findings
Nov 3, 2026
Merged

douzzer merged 1 commit into
wolfSSL:masterfrom
Frauschi:fix-clang-tidy-findings

Conversation

@Frauschi

@Frauschi Frauschi commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

The PRB clang-tidy legs have not run since the multi-test sandbox change; once https://github.com/wolfSSL/testing/pull/1093 lands, clang-tidy 14 reports three findings on master, which are fixed in this PR:

  • cert_test(): drop a dead ret = 0 (deadcode.DeadStores)
  • Sha3Update(): compute the block size once after the range check, avoiding a core.DivideZero false positive on the cSHAKE byte-pad path
  • GMULT macros: parenthesize the macro argument (bugprone-macro-parentheses)

- test.c cert_test(): the ret = 0 after the inhibitAnyPolicy check is never
  read (clang-analyzer-deadcode.DeadStores); every following path assigns
  ret before done.
- sha3.c Sha3Update(): clang-analyzer-core.DivideZero on len / (p * 8U).
  p is range-checked to 9..21, but on the CshakeBytePad path (entry with
  i == rate and len 0) the analyzer loses the range and treats p * 8U as
  zero. Computing the block size once into a local after the range check,
  as Sha3Final() does with rate, avoids the false positive.
- aes.c: parenthesize the macro argument in the three GMULT definitions
  (bugprone-macro-parentheses).
Copilot AI balanced review requested due to automatic review settings November 3, 2026 14:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the clang-tidy warning cleanup.

No open issues 🎉

What changed in this PR

This PR addresses clang-tidy 14 warnings in wolfCrypt’s certificate tests, SHA-3 implementation, and AES-GCM macros without intended behavior changes.

Changes:

  • Remove an unused assignment in cert_test().
  • Compute and reuse the validated SHA-3 block size to avoid a divide-by-zero false positive.
  • Parenthesize the cast argument in three GMULT macros.
File Description
wolfcrypt/​test/​test.c Remove a dead store after the inhibitAnyPolicy check.
wolfcrypt/​src/​sha3.c Reuse a local block size throughout Sha3Update().
wolfcrypt/​src/​aes.c Parenthesize m in three GMULT definitions.

Review effort: Balanced

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

@Frauschi

Frauschi commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Jenkins retest this please

@douzzer
douzzer merged commit 185dc45 into wolfSSL:master Nov 3, 2026
442 checks passed
@Frauschi
Frauschi deleted the fix-clang-tidy-findings branch November 3, 2026 17:30
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.

4 participants