From 5fd831a27ccd9f97e2eb4d82f64b486495a6d7f3 Mon Sep 17 00:00:00 2001 From: susisstrolch Date: Tue, 19 Jan 2016 09:22:59 +0100 Subject: [PATCH] more cleansing on DBG macro Because espmissingincludes.h contains a properly escaped definition for os_printf() macro, we can simplify the DBG definition. --- cmd/cmd.c | 14 +++++++------- cmd/handlers.c | 2 +- esp-link/cgi.c | 6 +++--- esp-link/cgiflash.c | 4 ++-- esp-link/cgimqtt.c | 6 +++--- esp-link/cgioptiboot.c | 2 +- esp-link/cgiservices.c | 12 ++++++------ esp-link/cgiwifi.c | 2 +- esp-link/log.c | 2 +- esp-link/mqtt_client.c | 2 +- httpd/httpd.c | 2 +- mqtt/mqtt_cmd.c | 2 +- serial/slip.c | 2 +- syslog/syslog.c | 2 +- user/user_main.c | 2 +- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/cmd/cmd.c b/cmd/cmd.c index 8f04faf..1f4c2a5 100644 --- a/cmd/cmd.c +++ b/cmd/cmd.c @@ -8,7 +8,7 @@ #include "uart.h" #ifdef CMD_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) static const char *cmd_names[] = { "NULL", "RESET", "IS_READY", "WIFI_CONNECT", "MQTT_SETUP", "MQTT_CONNECT", "MQTT_DISCONNECT", @@ -124,17 +124,17 @@ CMD_parse_packet(uint8_t *buf, short len) { CmdPacket *packet = (CmdPacket*)buf; uint8_t *data_ptr = (uint8_t*)&packet->args; uint8_t *data_limit = data_ptr+len; - + DBG("CMD_parse_packet: cmd=%d(%s) argc=%d cb=%p ret=%lu\n", - packet->cmd, - cmd_names[packet->cmd], - packet->argc, - (void *)packet->callback, + packet->cmd, + cmd_names[packet->cmd], + packet->argc, + (void *)packet->callback, packet->_return ); #if 0 - // print out arguments + // print out arguments uint16_t argn = 0; uint16_t argc = packet->argc; while (data_ptr+2 < data_limit && argc--) { diff --git a/cmd/handlers.c b/cmd/handlers.c index 4d20e4d..5baf821 100644 --- a/cmd/handlers.c +++ b/cmd/handlers.c @@ -13,7 +13,7 @@ #endif #ifdef CMD_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif diff --git a/esp-link/cgi.c b/esp-link/cgi.c index 081ef49..6959833 100644 --- a/esp-link/cgi.c +++ b/esp-link/cgi.c @@ -18,7 +18,7 @@ Some random cgi routines. #include "config.h" #ifdef CGI_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif @@ -202,7 +202,7 @@ int ICACHE_FLASH_ATTR cgiMenu(HttpdConnData *connData) { os_strncpy(name, flashConfig.hostname, 12); name[12] = 0; // construct json response - os_sprintf(buff, + os_sprintf(buff, "{ " "\"menu\": [ " "\"Home\", \"/home.html\", " @@ -216,7 +216,7 @@ int ICACHE_FLASH_ATTR cgiMenu(HttpdConnData *connData) { " ], " "\"version\": \"%s\", " "\"name\": \"%s\"" - " }", + " }", esp_link_version, name); httpdSend(connData, buff, -1); diff --git a/esp-link/cgiflash.c b/esp-link/cgiflash.c index 8c39e36..ccb1d45 100644 --- a/esp-link/cgiflash.c +++ b/esp-link/cgiflash.c @@ -20,7 +20,7 @@ Some flash handling cgi routines. Used for reading the existing flash and updati #include "cgiflash.h" #ifdef CGIFLASH_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif @@ -197,4 +197,4 @@ int ICACHE_FLASH_ATTR cgiReset(HttpdConnData *connData) { os_timer_setfn(&flash_reboot_timer, (os_timer_func_t *)system_restart, NULL); os_timer_arm(&flash_reboot_timer, 2000, 1); return HTTPD_CGI_DONE; -} \ No newline at end of file +} diff --git a/esp-link/cgimqtt.c b/esp-link/cgimqtt.c index 88aa6ed..09d6ce0 100644 --- a/esp-link/cgimqtt.c +++ b/esp-link/cgimqtt.c @@ -17,7 +17,7 @@ char *mqttState(void) { #include "cgimqtt.h" #ifdef CGIMQTT_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif @@ -134,7 +134,7 @@ int ICACHE_FLASH_ATTR cgiMqttSet(HttpdConnData *connData) { mqtt_client_init(); // if just enable changed we just need to bounce the client - } + } else if (mqtt_en_chg > 0) { DBG("MQTT server enable=%d changed\n", flashConfig.mqtt_enable); if (flashConfig.mqtt_enable && strlen(flashConfig.mqtt_host) > 0) @@ -154,7 +154,7 @@ int ICACHE_FLASH_ATTR cgiMqttSet(HttpdConnData *connData) { // if SLIP-enable is toggled it gets picked-up immediately by the parser int slip_update = getBoolArg(connData, "slip-enable", &flashConfig.slip_enable); if (slip_update < 0) return HTTPD_CGI_DONE; - if (slip_update > 0) + if (slip_update > 0) DBG("SLIP-enable changed: %d\n", flashConfig.slip_enable); DBG("Saving config\n"); diff --git a/esp-link/cgioptiboot.c b/esp-link/cgioptiboot.c index d9e20f1..da1cb2f 100644 --- a/esp-link/cgioptiboot.c +++ b/esp-link/cgioptiboot.c @@ -17,7 +17,7 @@ #define PGM_INTERVAL 200 // send sync at this interval in ms when in programming mode #ifdef OPTIBOOT_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif diff --git a/esp-link/cgiservices.c b/esp-link/cgiservices.c index 81f7200..3631dd9 100644 --- a/esp-link/cgiservices.c +++ b/esp-link/cgiservices.c @@ -7,7 +7,7 @@ #include "cgimqtt.h" #ifdef CGISERVICES_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif @@ -92,10 +92,10 @@ int ICACHE_FLASH_ATTR cgiSystemInfo(HttpdConnData *connData) { } void ICACHE_FLASH_ATTR cgiServicesSNTPInit() { - if (flashConfig.sntp_server[0] != '\0') { + if (flashConfig.sntp_server[0] != '\0') { sntp_stop(); if (true == sntp_set_timezone(flashConfig.timezone_offset)) { - sntp_setservername(0, flashConfig.sntp_server); + sntp_setservername(0, flashConfig.sntp_server); sntp_init(); } DBG("SNTP timesource set to %s with offset %d\n", flashConfig.sntp_server, flashConfig.timezone_offset); @@ -107,7 +107,7 @@ int ICACHE_FLASH_ATTR cgiServicesInfo(HttpdConnData *connData) { if (connData->conn == NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. - os_sprintf(buff, + os_sprintf(buff, "{ " "\"syslog_host\": \"%s\", " "\"syslog_minheap\": %d, " @@ -118,7 +118,7 @@ int ICACHE_FLASH_ATTR cgiServicesInfo(HttpdConnData *connData) { "\"sntp_server\": \"%s\", " "\"mdns_enable\": \"%s\", " "\"mdns_servername\": \"%s\"" - " }", + " }", flashConfig.syslog_host, flashConfig.syslog_minheap, flashConfig.syslog_filter, @@ -168,7 +168,7 @@ int ICACHE_FLASH_ATTR cgiServicesSet(HttpdConnData *connData) { int8_t mdns = 0; mdns |= getBoolArg(connData, "mdns_enable", &flashConfig.mdns_enable); if (mdns < 0) return HTTPD_CGI_DONE; - + if (mdns > 0) { if (flashConfig.mdns_enable){ DBG("Services: MDNS Enabled\n"); diff --git a/esp-link/cgiwifi.c b/esp-link/cgiwifi.c index 60d0d78..a76634c 100644 --- a/esp-link/cgiwifi.c +++ b/esp-link/cgiwifi.c @@ -22,7 +22,7 @@ Cgi/template routines for the /wifi url. #include "syslog.h" #ifdef CGIWIFI_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif diff --git a/esp-link/log.c b/esp-link/log.c index 821641f..d6c245b 100644 --- a/esp-link/log.c +++ b/esp-link/log.c @@ -7,7 +7,7 @@ #include "log.h" #ifdef LOG_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif diff --git a/esp-link/mqtt_client.c b/esp-link/mqtt_client.c index 12b9a8d..9b94576 100644 --- a/esp-link/mqtt_client.c +++ b/esp-link/mqtt_client.c @@ -5,7 +5,7 @@ #include "mqtt.h" #ifdef MQTTCLIENT_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__) } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif diff --git a/httpd/httpd.c b/httpd/httpd.c index 5590809..d6f0097 100644 --- a/httpd/httpd.c +++ b/httpd/httpd.c @@ -18,7 +18,7 @@ Esp8266 http server - core routines #include "httpd.h" #ifdef HTTPD_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...)os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif diff --git a/mqtt/mqtt_cmd.c b/mqtt/mqtt_cmd.c index 85cdfa1..3cca79b 100644 --- a/mqtt/mqtt_cmd.c +++ b/mqtt/mqtt_cmd.c @@ -8,7 +8,7 @@ #include "mqtt_cmd.h" #ifdef MQTTCMD_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif diff --git a/serial/slip.c b/serial/slip.c index b78369b..b9446e3 100644 --- a/serial/slip.c +++ b/serial/slip.c @@ -8,7 +8,7 @@ #include "cmd.h" #ifdef SLIP_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif diff --git a/syslog/syslog.c b/syslog/syslog.c index 5f60252..3d52735 100644 --- a/syslog/syslog.c +++ b/syslog/syslog.c @@ -17,7 +17,7 @@ extern void * mem_trim(void *m, size_t s); // not well documented... #ifdef SYSLOG_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif diff --git a/user/user_main.c b/user/user_main.c index e9d9917..fc32899 100644 --- a/user/user_main.c +++ b/user/user_main.c @@ -4,7 +4,7 @@ #define APPINIT_DBG #ifdef APPINIT_DBG -#define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) +#define DBG(format, ...) os_printf(format, ## __VA_ARGS__) #else #define DBG(format, ...) do { } while(0) #endif