Skip to content

fix(core-net): cast uint32_t grace_us for %u format specifier#3618

Open
vikramdattu wants to merge 2 commits into
warmcat:mainfrom
vikramdattu:fix/quic-grace-timer-format
Open

fix(core-net): cast uint32_t grace_us for %u format specifier#3618
vikramdattu wants to merge 2 commits into
warmcat:mainfrom
vikramdattu:fix/quic-grace-timer-format

Conversation

@vikramdattu

Copy link
Copy Markdown
Contributor

Problem

lib/core-net/client/connect3.c logs grace_us (a uint32_t) with a %u specifier:

uint32_t grace_us = 200000;
...
lwsl_wsi_notice(wsi, "QUIC socket created, starting grace timer %uus", grace_us);

On toolchains where uint32_t is typedef'd as long unsigned int (e.g. xtensa-esp-elf for ESP-IDF v5.3 / v5.4), %u (which expects unsigned int) mismatches the argument type and trips -Werror=format, failing the build:

connect3.c:967: error: format '%u' expects argument of type 'unsigned int',
  but argument 7 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]

(Found while building libwebsockets as a component on ESP-IDF. Toolchains where uint32_t is unsigned int don't warn, so it only shows on some targets.)

Fix

Cast to unsigned int to match the %u specifier — matching the existing logging idiom in core-net (rather than pulling in PRIu32). The value is a grace timer in microseconds and always fits.

lws-team and others added 2 commits June 19, 2026 17:48
connect3.c logs grace_us (uint32_t) with %u. On toolchains where uint32_t
is 'long unsigned int' (e.g. xtensa-esp-elf for ESP-IDF v5.3/v5.4) this
trips -Werror=format and fails the build. Cast to unsigned int to match
the specifier; the value (grace timer in us) always fits.
@sonarqubecloud

Copy link
Copy Markdown

@lws-team lws-team force-pushed the main branch 5 times, most recently from 4e74eb8 to 0013069 Compare June 20, 2026 09:39
vikramdattu added a commit to vikramdattu/esp-protocols that referenced this pull request Jun 20, 2026
warmcat/libwebsockets#3618 (cast uint32_t grace_us for the %u format
specifier in connect3.c) is now on main, so move the pin forward from
the temporary parent-commit pin to current main (00130694a). Verified:
examples/client builds clean on ESP-IDF v6.0 (esp32).
@lws-team lws-team force-pushed the main branch 2 times, most recently from 6eecf5a to b4b5aed Compare June 20, 2026 18:24
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.

2 participants