From c2dc09304cd6d822a0b4a5f6f5fe8035a503aca4 Mon Sep 17 00:00:00 2001 From: Alexey Gerenkov Date: Thu, 14 Jun 2018 19:11:21 +0300 Subject: [PATCH] gcc8_newlib3: Compilation warnings and errors not specific to newlib v3 --- .../app_trace/sys_view/esp32/SEGGER_RTT_esp32.c | 3 +-- components/coap/component.mk | 2 ++ components/coap/port/coap_io_socket.c | 4 ++-- components/console/argtable3/argtable3.c | 1 + components/cxx/cxx_exception_stubs.cpp | 15 +++++++++++++-- components/driver/rtc_module.c | 4 ++-- components/driver/sdio_slave.c | 2 +- components/esp32/clk.c | 2 +- components/esp32/include/esp_wifi_crypto_types.h | 2 +- components/expat/component.mk | 3 ++- components/expat/library/xmlparse.c | 4 +++- components/expat/library/xmltok_impl.c | 5 ++++- .../freertos/test/test_freertos_debug_functions.c | 2 +- components/libsodium/component.mk | 4 ++++ components/mbedtls/port/mbedtls_debug.c | 5 +++++ components/nghttp/port/http_parser.c | 4 ++-- components/wpa_supplicant/src/wpa2/tls/x509v3.c | 8 ++++++++ 17 files changed, 53 insertions(+), 17 deletions(-) diff --git a/components/app_trace/sys_view/esp32/SEGGER_RTT_esp32.c b/components/app_trace/sys_view/esp32/SEGGER_RTT_esp32.c index c8b199540..0cb92be55 100644 --- a/components/app_trace/sys_view/esp32/SEGGER_RTT_esp32.c +++ b/components/app_trace/sys_view/esp32/SEGGER_RTT_esp32.c @@ -20,7 +20,6 @@ #include "rom/ets_sys.h" #include "esp_app_trace.h" -#define LOG_LOCAL_LEVEL ESP_LOG_ERROR #include "esp_log.h" const static char *TAG = "segger_rtt"; @@ -125,7 +124,7 @@ unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, u uint8_t event_id = *pbuf; if (NumBytes > SYSVIEW_EVENTS_BUF_SZ) { - ESP_LOGE(TAG, "Too large event %d bytes!", NumBytes); + ESP_LOGE(TAG, "Too large event %u bytes!", NumBytes); return 0; } if (xPortGetCoreID()) { // dual core specific code diff --git a/components/coap/component.mk b/components/coap/component.mk index 012188d7a..4b3d56f56 100644 --- a/components/coap/component.mk +++ b/components/coap/component.mk @@ -12,3 +12,5 @@ COMPONENT_SUBMODULES += libcoap libcoap/src/debug.o: CFLAGS += -Wno-write-strings libcoap/src/pdu.o: CFLAGS += -Wno-write-strings +# Temporary suppress "fallthrough" warnings until they are fixed in libcoap repo +libcoap/src/option.o: CFLAGS += -Wno-implicit-fallthrough diff --git a/components/coap/port/coap_io_socket.c b/components/coap/port/coap_io_socket.c index eec8cc131..4c3f85b45 100644 --- a/components/coap/port/coap_io_socket.c +++ b/components/coap/port/coap_io_socket.c @@ -374,8 +374,8 @@ coap_network_read(coap_endpoint_t *ep, coap_packet_t **packet) { } /* local interface for IPv4 */ - (*packet)->src.size = sizeof((*packet)->src.addr); - memcpy(&(*packet)->src.addr.sa, &soc_srcipaddr, (*packet)->src.size); + (*packet)->src.size = sizeof((*packet)->src.addr.sa); + memcpy(&((*packet)->src.addr.sa), &soc_srcipaddr, (*packet)->src.size); if (len > coap_get_max_packetlength(*packet)) { /* FIXME: we might want to send back a response */ diff --git a/components/console/argtable3/argtable3.c b/components/console/argtable3/argtable3.c index 3fdda9068..282869f9c 100644 --- a/components/console/argtable3/argtable3.c +++ b/components/console/argtable3/argtable3.c @@ -3071,6 +3071,7 @@ static int trex_charnode(TRex *exp,TRexBool isclass) exp->_p++; return node; } //else default + /* falls through */ default: t = *exp->_p; exp->_p++; return trex_newnode(exp,t); diff --git a/components/cxx/cxx_exception_stubs.cpp b/components/cxx/cxx_exception_stubs.cpp index 3f7632c6d..b67bc2ad3 100644 --- a/components/cxx/cxx_exception_stubs.cpp +++ b/components/cxx/cxx_exception_stubs.cpp @@ -13,12 +13,23 @@ extern "C" void __cxx_fatal_exception(void) abort(); } +extern "C" bool __cxx_fatal_exception_bool(void) +{ + __cxx_fatal_exception(); + return false; +} + extern "C" void __cxx_fatal_exception_message(const char *msg) { printf("%s%s\n", FATAL_EXCEPTION, msg); abort(); } +extern "C" void __cxx_fatal_exception_message_va(const char *msg, ...) +{ + __cxx_fatal_exception_message(msg); +} + extern "C" void __cxx_fatal_exception_int(int i) { printf("%s (%d)\n", FATAL_EXCEPTION, i); @@ -43,7 +54,7 @@ void std::__throw_length_error(const char*) __attribute__((alias("__cxx_fatal_ex void std::__throw_out_of_range(const char*) __attribute__((alias("__cxx_fatal_exception_message"))); -void std::__throw_out_of_range_fmt(const char*, ...) __attribute__((alias("__cxx_fatal_exception_message"))); +void std::__throw_out_of_range_fmt(const char*, ...) __attribute__((alias("__cxx_fatal_exception_message_va"))); void std::__throw_runtime_error(const char*) __attribute__((alias("__cxx_fatal_exception_message"))); @@ -84,6 +95,6 @@ extern "C" void __cxa_rethrow(void) __attribute__((alias("__cxx_fatal_exception" extern "C" void __cxa_throw(void) __attribute__((alias("__cxx_fatal_exception"))); extern "C" void __cxa_call_terminate(void) __attribute__((alias("__cxx_fatal_exception"))); -bool std::uncaught_exception() __attribute__((alias("__cxx_fatal_exception"))); +bool std::uncaught_exception() __attribute__((alias("__cxx_fatal_exception_bool"))); #endif // CONFIG_CXX_EXCEPTIONS diff --git a/components/driver/rtc_module.c b/components/driver/rtc_module.c index 7c8f5ae69..333f50cc1 100644 --- a/components/driver/rtc_module.c +++ b/components/driver/rtc_module.c @@ -98,12 +98,12 @@ In ADC2, there're two locks used for different cases: adc2_spinlock should be acquired first, then adc2_wifi_lock or rtc_spinlock. */ //prevent ADC2 being used by wifi and other tasks at the same time. -static _lock_t adc2_wifi_lock = NULL; +static _lock_t adc2_wifi_lock; //prevent ADC2 being used by tasks (regardless of WIFI) portMUX_TYPE adc2_spinlock = portMUX_INITIALIZER_UNLOCKED; //prevent ADC1 being used by I2S dma and other tasks at the same time. -static _lock_t adc1_i2s_lock = NULL; +static _lock_t adc1_i2s_lock; typedef struct { TimerHandle_t timer; diff --git a/components/driver/sdio_slave.c b/components/driver/sdio_slave.c index e64802aa5..3892cb6b2 100644 --- a/components/driver/sdio_slave.c +++ b/components/driver/sdio_slave.c @@ -277,7 +277,7 @@ static inline uint8_t* sdio_ringbuf_offset_ptr(sdio_ringbuf_t *buf, sdio_ringbuf static esp_err_t sdio_ringbuf_send(sdio_ringbuf_t* buf, esp_err_t (*copy_callback)(uint8_t*, void*), void* arg, TickType_t wait) { portBASE_TYPE ret = xSemaphoreTake(buf->remain_cnt, wait); - if (ret != pdTRUE) return NULL; + if (ret != pdTRUE) return ESP_ERR_TIMEOUT; portENTER_CRITICAL(&buf->write_spinlock); uint8_t* get_ptr = sdio_ringbuf_offset_ptr(buf, ringbuf_write_ptr, buf->item_size); diff --git a/components/esp32/clk.c b/components/esp32/clk.c index 41b24c6ed..e6874e3f4 100644 --- a/components/esp32/clk.c +++ b/components/esp32/clk.c @@ -88,7 +88,7 @@ void esp_clk_init(void) break; default: freq_mhz = 80; - /* no break */ + /* falls through */ case 80: freq = RTC_CPU_FREQ_80M; break; diff --git a/components/esp32/include/esp_wifi_crypto_types.h b/components/esp32/include/esp_wifi_crypto_types.h index 0848f06ac..e1e2a51a1 100644 --- a/components/esp32/include/esp_wifi_crypto_types.h +++ b/components/esp32/include/esp_wifi_crypto_types.h @@ -607,7 +607,7 @@ typedef void (*esp_uuid_gen_mac_addr_t)(const unsigned char *mac_addr, unsigned * @brief free the message after finish DH * */ -typedef void * (*esp_dh5_free_t)(void *ctx); +typedef void (*esp_dh5_free_t)(void *ctx); /** * @brief Build WPS IE for (Re)Association Request diff --git a/components/expat/component.mk b/components/expat/component.mk index 0ee1199d1..bf34d3142 100644 --- a/components/expat/component.mk +++ b/components/expat/component.mk @@ -6,4 +6,5 @@ COMPONENT_ADD_INCLUDEDIRS := port/include include/expat COMPONENT_SRCDIRS := library port CFLAGS += -Wno-unused-function -DHAVE_EXPAT_CONFIG_H - +# Temporary suppress "fallthrough" warnings until they are fixed in expat repo +CFLAGS += -Wno-implicit-fallthrough diff --git a/components/expat/library/xmlparse.c b/components/expat/library/xmlparse.c index e69622bcf..0f9c7ae78 100644 --- a/components/expat/library/xmlparse.c +++ b/components/expat/library/xmlparse.c @@ -1554,6 +1554,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) errorCode = XML_ERROR_NO_MEMORY; return XML_STATUS_ERROR; } + /* falls through */ default: ps_parsing = XML_PARSING; } @@ -1680,6 +1681,7 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal) errorCode = XML_ERROR_NO_MEMORY; return XML_STATUS_ERROR; } + /* falls through */ default: ps_parsing = XML_PARSING; } @@ -4266,8 +4268,8 @@ doProlog(XML_Parser parser, return XML_ERROR_NO_MEMORY; declEntity->publicId = NULL; } - /* fall through */ #endif /* XML_DTD */ + /* falls through */ case XML_ROLE_ENTITY_SYSTEM_ID: if (dtd->keepProcessing && declEntity) { declEntity->systemId = poolStoreString(&dtd->pool, enc, diff --git a/components/expat/library/xmltok_impl.c b/components/expat/library/xmltok_impl.c index 5f779c057..b78512998 100644 --- a/components/expat/library/xmltok_impl.c +++ b/components/expat/library/xmltok_impl.c @@ -47,6 +47,7 @@ *nextTokPtr = ptr; \ return XML_TOK_INVALID; \ } \ + /* fall through */ \ case BT_NMSTRT: \ case BT_HEX: \ case BT_DIGIT: \ @@ -75,6 +76,7 @@ *nextTokPtr = ptr; \ return XML_TOK_INVALID; \ } \ + /* fall through */ \ case BT_NMSTRT: \ case BT_HEX: \ ptr += MINBPC(enc); \ @@ -575,7 +577,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end, return XML_TOK_INVALID; } } - /* fall through */ + /* fall through */ case BT_EQUALS: { int open; @@ -1403,6 +1405,7 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, case BT_NMSTRT: if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f)) break; + /* fall through */ default: switch (BYTE_TO_ASCII(enc, ptr)) { case 0x24: /* $ */ diff --git a/components/freertos/test/test_freertos_debug_functions.c b/components/freertos/test/test_freertos_debug_functions.c index 70c1b5b0c..0a6e14735 100644 --- a/components/freertos/test/test_freertos_debug_functions.c +++ b/components/freertos/test/test_freertos_debug_functions.c @@ -16,7 +16,7 @@ #if (CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE > 0) #define NO_OF_QUEUES_PER_CORE ((int)((CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE - 3)/portNUM_PROCESSORS)) //Save space for some preallocated tasks #define NO_OF_QUEUES_TOTAL (NO_OF_QUEUES_PER_CORE * portNUM_PROCESSORS) -#define QUEUE_NAME_MAX_LENGTH 10 +#define QUEUE_NAME_MAX_LENGTH 30 static SemaphoreHandle_t start_sem[portNUM_PROCESSORS]; static SemaphoreHandle_t done_sem = NULL; diff --git a/components/libsodium/component.mk b/components/libsodium/component.mk index 9862a274b..12dcb571a 100644 --- a/components/libsodium/component.mk +++ b/components/libsodium/component.mk @@ -86,3 +86,7 @@ CFLAGS += -DNATIVE_LITTLE_ENDIAN -DHAVE_WEAK_SYMBOLS -D__STDC_LIMIT_MACROS -D__ # randombytes.c needs to pull in platform-specific implementation $(LSRC)/randombytes/randombytes.o: CFLAGS+=-DRANDOMBYTES_DEFAULT_IMPLEMENTATION + +# Temporary suppress "fallthrough" warnings until they are fixed in libsodium repo +$(LSRC)/crypto_shorthash/siphash24/ref/shorthash_siphashx24_ref.o: CFLAGS += -Wno-implicit-fallthrough +$(LSRC)/crypto_shorthash/siphash24/ref/shorthash_siphash24_ref.o: CFLAGS += -Wno-implicit-fallthrough diff --git a/components/mbedtls/port/mbedtls_debug.c b/components/mbedtls/port/mbedtls_debug.c index e9f038b6a..316a76a99 100644 --- a/components/mbedtls/port/mbedtls_debug.c +++ b/components/mbedtls/port/mbedtls_debug.c @@ -34,12 +34,16 @@ void mbedtls_esp_enable_debug_log(mbedtls_ssl_config *conf, int threshold) switch(threshold) { case 1: level = ESP_LOG_WARN; + break; case 2: level = ESP_LOG_INFO; + break; case 3: level = ESP_LOG_DEBUG; + break; case 4: level = ESP_LOG_VERBOSE; + break; } esp_log_level_set(TAG, level); } @@ -76,6 +80,7 @@ static void mbedtls_esp_debug(void *ctx, int level, break; case 3: ESP_LOGD(TAG, "%s:%d %s", file, line, str); + break; case 4: ESP_LOGV(TAG, "%s:%d %s", file, line, str); break; diff --git a/components/nghttp/port/http_parser.c b/components/nghttp/port/http_parser.c index 3c896ffad..8c1f4dd07 100644 --- a/components/nghttp/port/http_parser.c +++ b/components/nghttp/port/http_parser.c @@ -1814,7 +1814,7 @@ reexecute: case 2: parser->upgrade = 1; - + /* falls through */ case 1: parser->flags |= F_SKIPBODY; break; @@ -2374,7 +2374,7 @@ http_parser_parse_url(const char *buf, size_t buflen, int is_connect, case s_req_server_with_at: found_at = 1; - /* FALLTROUGH */ + /* falls through */ case s_req_server: uf = UF_HOST; break; diff --git a/components/wpa_supplicant/src/wpa2/tls/x509v3.c b/components/wpa_supplicant/src/wpa2/tls/x509v3.c index f7962db81..66a0e448e 100644 --- a/components/wpa_supplicant/src/wpa2/tls/x509v3.c +++ b/components/wpa_supplicant/src/wpa2/tls/x509v3.c @@ -494,20 +494,28 @@ static char * x509_name_attr_str(enum x509_name_attr_type type) switch (type) { case X509_NAME_ATTR_NOT_USED: strcpy(name_attr, "[N/A]"); + break; case X509_NAME_ATTR_DC: strcpy(name_attr, "DC"); + break; case X509_NAME_ATTR_CN: strcpy(name_attr, "CN"); + break; case X509_NAME_ATTR_C: strcpy(name_attr, "C"); + break; case X509_NAME_ATTR_L: strcpy(name_attr, "L"); + break; case X509_NAME_ATTR_ST: strcpy(name_attr, "ST"); + break; case X509_NAME_ATTR_O: strcpy(name_attr, "O"); + break; case X509_NAME_ATTR_OU: strcpy(name_attr, "OU"); + break; default : strcpy(name_attr, "?"); }