Skip to content

libs/libc/stream: Fix the shadowed len in vsprintf_internal(). - #21210

Merged
acassis merged 1 commit into
apache:masterfrom
casaroli:vsprintf-shadow-up
Oct 30, 2026
Merged

acassis merged 1 commit into
apache:masterfrom
casaroli:vsprintf-shadow-up

Conversation

@casaroli

Copy link
Copy Markdown
Contributor

Summary

fee2c2e ("libc/stdio: Batch vsprintf literal output", #21072) added two inner variables size_t len in vsprintf_internal(), which shadow the unsigned char len of the function. arm64 builds with -Wshadow -Werror (arch/arm64/src/Toolchain.defs), so every arm64 build of master fails:

stream/lib_libvsprintf.c:219:26: error: declaration of 'len' shadows a previous local [-Werror=shadow]
stream/lib_libvsprintf.c:232:22: error: declaration of 'len' shadows a previous local [-Werror=shadow]

This PR renames the two inner variables to litlen. No functional change.

Impact

Build fix only: a rename of two local variables, all build modes and architectures.

Testing

Before (master 8773241), qemu-armv8a:nsh: the build fails with the two errors above.

After, with this PR (QEMU with HVF):

  • qemu-armv8a:knsh (kernel build): ostest exits with status 0; a test program printflit.c checks literal text, %% and padding (the output paths that libc/stdio: Batch vsprintf output #21072 changed) with snprintf() against the C standard results: 8 of 8 PASS ("plain text only", "%", "a%b%%c", "x42y", "[ 42][42 ][00042]", "[ ab][ab ]", a 40-wide field, "s%c end").
  • qemu-armv8a:nsh (flat build): ostest exits with status 0.
  • qemu-armv8a:nsh with CONFIG_LIBC_NUMBERED_ARGS=y (the other branch of the changed code): builds, no warning in lib_libvsprintf.c.
  • mps2-an500:nsh (32-bit Arm, -Wshadow without -Werror): builds, no warning in lib_libvsprintf.c.

tools/checkpatch.sh -c -u -m -g passes.

fee2c2e ("libc/stdio: Batch vsprintf literal output") added two
inner variables `size_t len`, which shadow the `unsigned char len` of
vsprintf_internal().  arm64 builds with -Wshadow -Werror
(arch/arm64/src/Toolchain.defs), so every arm64 build failed:

  stream/lib_libvsprintf.c:219:26: error: declaration of 'len' shadows
  a previous local [-Werror=shadow]

Rename the two inner variables to litlen.  No functional change.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
@github-actions github-actions Bot added Area: OS Components OS Components issues Size: S The size of the change in this PR is small labels Oct 30, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

qemu-armv8a

  • Code: .rodata +32 B, .text.mm_memalign +12 B, .text.vsprintf_internal.constprop.0 -72 B (+0.0%, 354,144 B)

No memory changes detected for:


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

@acassis
acassis merged commit 7877d3e into apache:master Oct 30, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: OS Components OS Components issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants