[GH-ISSUE #1717] Avoid compiler warning. Wrong specifier used for printf statement. #1457

Open
opened 2026-02-28 01:30:09 +03:00 by kerem · 3 comments
Owner

Originally created by @HenkHoldijk on GitHub (Mar 3, 2024).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1717

Compiling for the ESP32-C3 using the Arduino IDE 1.8.19 results in a compiler warning for WiFiManager.cpp on line 3368.

Original line : "_debugPort.printf("[MEM] free: %5d | max: %5d | frag: %3d%% \n", free, max, frag);"

The %5d does not match the uint32_t free type.

Replace with : "_debugPort.printf("[MEM] free: %5ld | max: %5d | frag: %3d%% \n", free, max, frag);"

Originally created by @HenkHoldijk on GitHub (Mar 3, 2024). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1717 Compiling for the ESP32-C3 using the Arduino IDE 1.8.19 results in a compiler warning for WiFiManager.cpp on line 3368. Original line : "_debugPort.printf("[MEM] free: %5d | max: %5d | frag: %3d%% \n", free, max, frag);" The %5d does not match the uint32_t free type. Replace with : "_debugPort.printf("[MEM] free: %5ld | max: %5d | frag: %3d%% \n", free, max, frag);"
Author
Owner

@tablatronix commented on GitHub (Mar 3, 2024):

Hmm I would think free and max should be the same type also

<!-- gh-comment-id:1975326018 --> @tablatronix commented on GitHub (Mar 3, 2024): Hmm I would think free and max should be the same type also
Author
Owner
<!-- gh-comment-id:1975329722 --> @tablatronix commented on GitHub (Mar 3, 2024): https://github.com/espressif/arduino-esp32/blob/aed7b4fa598765db61678d3253401b8cd64a8ec8/cores/esp32/chip-debug-report.cpp#L25
Author
Owner

@HenkHoldijk commented on GitHub (Mar 3, 2024):

Agree regarding the max. The frag is OK.

Currently they are declared as:
uint32_t free = info.total_free_bytes;
uint16_t max = info.largest_free_block;
uint8_t frag = 100 - (max * 100) / free;

Should be:
uint32_t free = info.total_free_bytes;
uint32_t max = info.largest_free_block;
uint8_t frag = 100 - (max * 100) / free;

The printf then becomes : _debugPort.printf("[MEM] free: %5ld | max: %5ld | frag: %3d%% \n", free, max, frag);

<!-- gh-comment-id:1975389890 --> @HenkHoldijk commented on GitHub (Mar 3, 2024): Agree regarding the max. The frag is OK. Currently they are declared as: uint32_t free = info.total_free_bytes; uint16_t max = info.largest_free_block; uint8_t frag = 100 - (max * 100) / free; Should be: uint32_t free = info.total_free_bytes; uint32_t max = info.largest_free_block; uint8_t frag = 100 - (max * 100) / free; The printf then becomes : _debugPort.printf("[MEM] free: %5ld | max: %5ld | frag: %3d%% \n", free, max, frag);
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1457
No description provided.