Skip to content

memory.c: guard wc_MemFailCount_AllocFailed to its call-site config - #12085

Open
danielinux wants to merge 2 commits into
wolfSSL:masterfrom
danielinux:memory-memfailcount-guard
Open

danielinux wants to merge 2 commits into
wolfSSL:masterfrom
danielinux:memory-memfailcount-guard

Conversation

@danielinux

Copy link
Copy Markdown
Member

Found by mc/dc campaign.

All three call sites (the TRAP_MALLOC_SZ path, the FORCE_MALLOC_FAIL_TEST path, and the plain wolfSSL_Malloc path) live in the !WOLFSSL_STATIC_MEMORY allocator. The definition is gated only on WOLFSSL_MEM_FAIL_COUNT, so a build with WOLFSSL_STATIC_MEMORY + WOLFSSL_MEM_FAIL_COUNT (a valid test configuration, and the one tests/unit-mcdc/test_memory_whitebox.c compiles memory.c under) leaves the static function unused and breaks -Werror,-Wunused-function builds.

Restrict the definition to !WOLFSSL_STATIC_MEMORY, matching its callers.

Verified: strict white-box compile (the memory white-box TU with the library's -Werror flags, no -Wno-error=unused-function) fails on origin/master with exactly 'unused function wc_MemFailCount_AllocFailed' and passes with this guard; guard matrix compiles clean (static+failcount, non-static+failcount, +TRAP_MALLOC_SZ, +FORCE_MALLOC_FAIL_TEST, static only); infra MC/DC module green end-to-end.

Testing

How did you test?

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

All three call sites (the TRAP_MALLOC_SZ path, the FORCE_MALLOC_FAIL_TEST
path, and the plain wolfSSL_Malloc path) live in the !WOLFSSL_STATIC_MEMORY
allocator. The definition is gated only on WOLFSSL_MEM_FAIL_COUNT, so a
build with WOLFSSL_STATIC_MEMORY + WOLFSSL_MEM_FAIL_COUNT (a valid test
configuration, and the one tests/unit-mcdc/test_memory_whitebox.c compiles
memory.c under) leaves the static function unused and breaks
-Werror,-Wunused-function builds.

Restrict the definition to !WOLFSSL_STATIC_MEMORY, matching its callers.

Verified: strict white-box compile (the memory white-box TU with the
library's -Werror flags, no -Wno-error=unused-function) fails on
origin/master with exactly 'unused function wc_MemFailCount_AllocFailed'
and passes with this guard; guard matrix compiles clean (static+failcount,
non-static+failcount, +TRAP_MALLOC_SZ, +FORCE_MALLOC_FAIL_TEST, static
only); infra MC/DC module green end-to-end.
Copilot AI balanced review requested due to automatic review settings November 10, 2026 23:27

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +20 B, text +10,016 B (+3.6%, 292,508 B / 67,108,864 B, total: 0% used)
  • RAM: bss +49 B, datas +16 B (+0.1%, 58,423 B / 983,040 B, total: 6% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #12085

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Review tier: Max

Comment thread wolfcrypt/src/memory.c Resolved

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #12085

Scan targets checked: wolfcrypt-src, wolfcrypt-bugs
Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review November 10, 2026 23:54

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

@danielinux

Copy link
Copy Markdown
Member Author

jenkins retest this please
timing flake in nonblocking socket test

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.

5 participants