Skip to content

Commit e5b4de3

Browse files
authored
fix DEBUG macros (#5728)
* fix DEBUG macros All fmt strings in flash fix #5658 This also allows to avoid warnings and easy mistakes with (no brace): if (something) DEBUGV("blah"); * use newlib unaligned-compatible printf for DEBUGV * remove useless putprintf since ::printf already uses ets_putc
1 parent 9365f6d commit e5b4de3

File tree

7 files changed

+10
-11
lines changed

7 files changed

+10
-11
lines changed

cores/esp8266/debug.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@ void ICACHE_RAM_ATTR hexdump(const void *mem, uint32_t len, uint8_t cols) {
3434
}
3535
os_printf("\n");
3636
}
37-

cores/esp8266/debug.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#include <stdint.h>
66

77
#ifdef DEBUG_ESP_CORE
8-
#define DEBUGV(...) ets_printf(__VA_ARGS__)
8+
#define DEBUGV(fmt, ...) ::printf((PGM_P)PSTR(fmt), ## __VA_ARGS__)
99
#endif
1010

1111
#ifndef DEBUGV
12-
#define DEBUGV(...)
12+
#define DEBUGV(...) do { (void)0; } while (0)
1313
#endif
1414

1515
#ifdef __cplusplus

libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#endif
4343

4444
#ifndef DEBUG_HTTPCLIENT
45-
#define DEBUG_HTTPCLIENT(...)
45+
#define DEBUG_HTTPCLIENT(...) do { (void)0; } while (0)
4646
#endif
4747

4848
#define HTTPCLIENT_DEFAULT_TCP_TIMEOUT (5000)

libraries/ESP8266WiFi/src/ESP8266WiFi.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extern "C" {
5050
#endif
5151

5252
#ifndef DEBUG_WIFI
53-
#define DEBUG_WIFI(...)
53+
#define DEBUG_WIFI(...) do { (void)0; } while (0)
5454
#endif
5555

5656

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929

3030
#ifdef DEBUG_ESP_WIFI
3131
#ifdef DEBUG_ESP_PORT
32-
#define DEBUG_WIFI_GENERIC(fmt, ...) DEBUG_ESP_PORT.printf( (PGM_P)PSTR(fmt), ##__VA_ARGS__ )
32+
#define DEBUG_WIFI_GENERIC(fmt, ...) DEBUG_ESP_PORT.printf_P( (PGM_P)PSTR(fmt), ##__VA_ARGS__ )
3333
#endif
3434
#endif
3535

3636
#ifndef DEBUG_WIFI_GENERIC
37-
#define DEBUG_WIFI_GENERIC(...)
37+
#define DEBUG_WIFI_GENERIC(...) do { (void)0; } while (0)
3838
#endif
3939

4040
struct WiFiEventHandlerOpaque;

libraries/ESP8266WiFi/src/ESP8266WiFiMulti.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232

3333
#ifdef DEBUG_ESP_WIFI
3434
#ifdef DEBUG_ESP_PORT
35-
#define DEBUG_WIFI_MULTI(fmt, ...) DEBUG_ESP_PORT.printf( (PGM_P)PSTR(fmt), ##__VA_ARGS__ )
35+
#define DEBUG_WIFI_MULTI(fmt, ...) DEBUG_ESP_PORT.printf_P( (PGM_P)PSTR(fmt), ##__VA_ARGS__ )
3636
#endif
3737
#endif
3838

3939
#ifndef DEBUG_WIFI_MULTI
40-
#define DEBUG_WIFI_MULTI(...)
40+
#define DEBUG_WIFI_MULTI(...) do { (void)0; } while (0)
4141
#endif
4242

4343
struct WifiAPEntry {

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636

3737
#ifdef DEBUG_ESP_HTTP_UPDATE
3838
#ifdef DEBUG_ESP_PORT
39-
#define DEBUG_HTTP_UPDATE(...) DEBUG_ESP_PORT.printf( __VA_ARGS__ )
39+
#define DEBUG_HTTP_UPDATE(fmt, ...) DEBUG_ESP_PORT.printf_P( (PGM_P)PSTR(fmt), ## __VA_ARGS__ )
4040
#endif
4141
#endif
4242

4343
#ifndef DEBUG_HTTP_UPDATE
44-
#define DEBUG_HTTP_UPDATE(...)
44+
#define DEBUG_HTTP_UPDATE(...) do { (void)0; } while(0)
4545
#endif
4646

4747
/// note we use HTTP client errors too so we start at 100

0 commit comments

Comments
 (0)