Skip to content

Commit 7090299

Browse files
authored
fix: compiler warnings about printf-format for pointers in esp32-hal-cpu.c (#6705)
* fix(hal.cpu) compiler warn about printf-format for pointers > 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=] ``` * fix(tone.cpp) compiler warn about printf-format for pointers > 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=] ```
1 parent bdeef89 commit 7090299

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

cores/esp32/Tone.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void tone_task(void*){
2828
xQueueReceive(_tone_queue, &tone_msg, portMAX_DELAY);
2929
switch(tone_msg.tone_cmd){
3030
case TONE_START:
31-
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);
31+
log_d("Task received from queue TONE_START: _pin=%d, frequency=%u Hz, duration=%lu ms", tone_msg.pin, tone_msg.frequency, tone_msg.duration);
3232

3333
log_d("Setup LED controll on channel %d", _channel);
3434
// ledcSetup(_channel, tone_msg.frequency, 11);
@@ -118,7 +118,7 @@ void noTone(uint8_t _pin){
118118
// duration - time in ms - how long will the signal be outputted.
119119
// If not provided, or 0 you must manually call noTone to end output
120120
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration){
121-
log_d("_pin=%d, frequency=%u Hz, duration=%u ms", _pin, frequency, duration);
121+
log_d("_pin=%d, frequency=%u Hz, duration=%lu ms", _pin, frequency, duration);
122122
if(tone_init()){
123123
tone_msg_t tone_msg = {
124124
.tone_cmd = TONE_START,

cores/esp32/esp32-hal-cpu.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ bool addApbChangeCallback(void * arg, apb_change_cb_t cb){
107107
// look for duplicate callbacks
108108
while( (r != NULL ) && !((r->cb == cb) && ( r->arg == arg))) r = r->next;
109109
if (r) {
110-
log_e("duplicate func=%08X arg=%08X",c->cb,c->arg);
110+
log_e("duplicate func=%8p arg=%8p",c->cb,c->arg);
111111
free(c);
112112
xSemaphoreGive(apb_change_lock);
113113
return false;
@@ -129,7 +129,7 @@ bool removeApbChangeCallback(void * arg, apb_change_cb_t cb){
129129
// look for matching callback
130130
while( (r != NULL ) && !((r->cb == cb) && ( r->arg == arg))) r = r->next;
131131
if ( r == NULL ) {
132-
log_e("not found func=%08X arg=%08X",cb,arg);
132+
log_e("not found func=%8p arg=%8p",cb,arg);
133133
xSemaphoreGive(apb_change_lock);
134134
return false;
135135
}

0 commit comments

Comments
 (0)