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

fix: compiler warnings about printf-format for pointers in esp32-hal-cpu.c #6705

Merged
merged 3 commits into from
May 9, 2022

Conversation

ankostis
Copy link
Contributor

@ankostis ankostis commented May 6, 2022

the compiler complains about these 2 places in esp32-hal-cpu.cpp of miss-matching %X to function & void pointers,
and x2 in Tone.cpp miss-matching uint with `long uint.

Sample warning messages:

.../framework-arduinoespressif32/cores/esp32/esp32-hal-cpu.c:132:9: note: in expansion of macro 'log_e'
         log_e("not found func=%08X arg=%08X",cb,arg);
         ^~~~~
.../framework-arduinoespressif32/tools/sdk/esp32/include/log/include/esp_log.h:276:27: warning: format '%X' expects argument of type 'unsigned int', but argument 7 has type 'void *' [-Wformat=]

I believe the correct should be %p, but i preserved the 8-width in my PR.
(cannot really test the code, this fix just stops the compiler warnings).

Steps to Reproduce

To get those warnings, i had to enable -Wformat build-flag and define DUSE_ESP_IDF_LOG 1,
so the esp_idf log-routines to apply, that they are appropriately marked with __attribute__ (( format(...) ))).

warning was:
```
framework-arduinoespressif32/cores/esp32/esp32-hal-cpu.c:132:9: note: in expansion of macro 'log_e'
         log_e("not found func=%08X arg=%08X",cb,arg);
         ^~~~~
framework-arduinoespressif32/tools/sdk/esp32/include/log/include/esp_log.h:276:27: warning: format '%X' expects argument of type 'unsigned int', but argument 7 has type 'void *' [-Wformat=]

```
@github-actions
Copy link
Contributor

github-actions bot commented May 6, 2022

Unit Test Results

0 files  0 suites   0s ⏱️
0 tests 0 ✔️ 0 💤 0

Results for commit c6ef73b.

♻️ This comment has been updated with latest results.

format-str expected plain uint while `duration` is long-uint.

Warning was:
```
.../cores/esp32/esp32-hal-log.h:115:32: note: in expansion of macro 'ESP_LOG_LEVEL_LOCAL'
 #define log_d(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_DEBUG, TAG, format, ##__VA_ARGS__);}while(0)
                                ^~~~~~~~~~~~~~~~~~~
.../cores/esp32/Tone.cpp:31:9: note: in expansion of macro 'log_d'
         log_d("Task received from queue TONE_START: _pin=%d, frequency=%u Hz, duration=%u ms", tone_msg.pin, tone_msg.frequency, tone_msg.duration);
         ^~~~~
.../tools/sdk/esp32/include/log/include/esp_log.h:276:27: warning: format '%u' expects argument of type 'unsigned int', but argument 8 has type 'long unsigned int' [-Wformat=]
```
@ankostis
Copy link
Contributor Author

ankostis commented May 6, 2022

Discovered another x2 issues in Tone.cpp,

  • commit appended,
  • OP above amended.

@me-no-dev
Copy link
Member

Thanks @ankostis :)

@me-no-dev me-no-dev merged commit 7090299 into espressif:master May 9, 2022
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.

3 participants