Add 32-bit CI job, fix sign-compare warnings in POSIX flash port - #491
Add 32-bit CI job, fix sign-compare warnings in POSIX flash port#491yosuke-wolfssl wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new 32-bit (-m32) GitHub Actions job to ensure wolfHSM is built/tested at the word size used by supported ports, and adjusts the POSIX flash-file backend to avoid 32-bit sign/width pitfalls surfaced by the new CI coverage.
Changes:
- Add a new Ubuntu-only
build-32bitCI job that builds and runs both test-refactor targets and the legacytest/suite under-m32. - Fix several 32-bit sign-compare issues in
posix_flash_file.cby making byte-count checks robust againstssize_tvsuint32_tcomparisons. - Rework
MAX_OFFSET/pfill()typing to avoid wrap/narrowing issues and negative aliasing at larger sizes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| port/posix/posix_flash_file.c | Adjusts offset/size handling and helper return types to behave correctly under 32-bit widths and -Werror. |
| .github/workflows/build-and-test-refactor.yml | Adds a dedicated 32-bit CI job that builds/runs refactor + legacy suites with ARCHFLAGS=-m32. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4cec832 to
e44728d
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #491
Scan targets checked: wolfhsm-core-bugs, wolfhsm-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
e44728d to
a0d1438
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #491
Scan targets checked: wolfhsm-core-bugs, wolfhsm-src
No new issues found in the changed files. ✅
|
|
||
| /* The flash interface addresses with uint32_t offsets and seeks with | ||
| * off_t, so reject a partition whose doubled size exceeds either */ | ||
| if ((max_offset > 0xFFFFFFFFu) || |
There was a problem hiding this comment.
use constants from limits.h
Problem
No CI job builds or runs wolfHSM at 32-bit width, yet every supported port is
32-bit. The AES
needed_sizeoverflow class #487 only triggers at 32 bits, so it wasinvisible to every gate. Adding a 32-bit job also surfaced width bugs in the
POSIX flash port that a 64-bit host silently hides.
Fix (
port/posix/posix_flash_file.c)off_t/ssize_t-vs-uint32_tcomparisons that fail-Werrorat 32 bits. Therc != sizebyte-count checks became(rc < 0) || ((size_t)rc != (size_t)size).MAX_OFFSET: now computed inuint64_tso the doubling can't wrap and the_Initcomparisons stay unsigned at every width — avoids a signed narrowingthat could take a large
partition_sizeintoftruncate(<negative>).pfill(): returns anintstatus (0/-1) instead of asize_tcountcast to
ssize_t, which aliased negative above 2 GiB and tripped the newrc < 0guard.CI (
.github/workflows/build-and-test-refactor.yml)New ubuntu-only
build-32bitjob (gcc-multilib), parallel to the 64-bit matrix:SHE=1 DMA=1test/suitePOSIX_FLASH_FILE_CB; refactor uses the RAM simNOCRYPTO=1ARCHFLAGSis passed tomake runtoo, so a stale rebuild can't switch arch mid-step.Verification
64-bit and 32-bit (i386/QEMU) match exactly: default 43/26/0,
SHE+DMA53/16/0,NOCRYPTO16/53/0, legacy suite exit 0. Zero warnings,-Werrorintact —including the legacy tree's
-Wpointer-arith, never compiled at 32-bit before.Built against wolfSSL master tip, so no upstream
-Werrorrelaxation is needed.The legacy run executes
posixFlashFile_*for the first time at 32-bit width;a negative control (neutered
pfill()) aborts that suite, confirming the step gates.