Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid compiler warning. Wrong specifier used for printf statement. #1717

Open
HenkHoldijk opened this issue Mar 3, 2024 · 3 comments
Open

Comments

@HenkHoldijk
Copy link

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);"

@tablatronix
Copy link
Collaborator

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

@HenkHoldijk
Copy link
Author

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants