]> granicus.if.org Git - esp-idf/commitdiff
Resolve problems found by enabling -Wwrite-strings compilation flag
authorRoland Dobai <dobai.roland@gmail.com>
Mon, 9 Apr 2018 10:58:35 +0000 (12:58 +0200)
committerRoland Dobai <dobai.roland@gmail.com>
Tue, 10 Apr 2018 06:53:43 +0000 (08:53 +0200)
18 files changed:
components/bootloader/subproject/main/bootloader_start.c
components/bt/bluedroid/btc/core/btc_ble_storage.c
components/bt/bluedroid/btc/core/btc_config.c
components/bt/bluedroid/btc/include/btc_config.h
components/bt/bluedroid/osi/config.c
components/bt/bluedroid/osi/include/config.h
components/bt/bluedroid/stack/btm/btm_sec.c
components/bt/bluedroid/stack/include/btm_api.h
components/coap/component.mk
components/console/argtable3/argtable3.c
components/esp32/gdbstub.c
components/fatfs/test/test_fatfs_common.c
components/newlib/test/test_newlib.c
components/openssl/library/ssl_lib.c
components/spiffs/test/test_spiffs.c
examples/bluetooth/gatt_security_client/main/example_ble_sec_gattc_demo.c
examples/protocols/http2_request/components/sh2lib/sh2lib.c
examples/protocols/pppos_client/main/pppos_client_main.c

index c20273cec19c9596eeb3e4fea2a09a68200467be..37a3af9692a17302ed66bad90212b071afaff079 100644 (file)
@@ -141,7 +141,7 @@ bool load_partition_table(bootloader_state_t* bs)
 {
     const esp_partition_info_t *partitions;
     const int ESP_PARTITION_TABLE_DATA_LEN = 0xC00; /* length of actual data (signature is appended to this) */
-    char *partition_usage;
+    const char *partition_usage;
     esp_err_t err;
     int num_partitions;
 
@@ -900,7 +900,7 @@ static void wdt_reset_info_dump(int cpu)
 {
     uint32_t inst = 0, pid = 0, stat = 0, data = 0, pc = 0,
              lsstat = 0, lsaddr = 0, lsdata = 0, dstat = 0;
-    char *cpu_name = cpu ? "APP" : "PRO";
+    const char *cpu_name = cpu ? "APP" : "PRO";
 
     if (cpu == 0) {
         stat    = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_STATUS_REG);
index 3c260642815977a91fda29f395d0fca3674262f3..e2c2b6d3f82d32b16cee5ab6314150f297fb0419 100644 (file)
@@ -392,7 +392,7 @@ bool _btc_storage_compare_address_key_value(bt_bdaddr_t *remote_bd_addr,
 {
     bdstr_t bdstr;
     bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
-    char *key_type_str;
+    const char *key_type_str;
     switch (key_type) {
     case BTM_LE_KEY_PENC:
         key_type_str = BTC_BLE_STORAGE_LE_KEY_PENC_STR;
index 7b733ae7b9e800c6723b6ee5b9de34172a15d39d..df95701385fc1a0094a0c0378512d10ddcefde6c 100644 (file)
@@ -36,7 +36,7 @@ static void btc_key_value_to_string(uint8_t *key_value, char *value_str, int key
 static osi_mutex_t lock;  // protects operations on |config|.
 static config_t *config;
 
-bool btc_compare_address_key_value(const char *section, char *key_type, void *key_value, int key_length)
+bool btc_compare_address_key_value(const char *section, const char *key_type, void *key_value, int key_length)
 {
     assert(key_value != NULL);
     bool status = false;
index 79f6137e85190495fbc0b015aadd10e011426141..dfbdcdbadfe1bf1b916a5e6833a2bd20b40e8291 100644 (file)
@@ -49,7 +49,7 @@ int btc_config_clear(void);
 
 // TODO(zachoverflow): Eww...we need to move these out. These are peer specific, not config general.
 bool btc_get_address_type(const BD_ADDR bd_addr, int *p_addr_type);
-bool btc_compare_address_key_value(const char *section, char *key_type, void *key_value, int key_length);
+bool btc_compare_address_key_value(const char *section, const char *key_type, void *key_value, int key_length);
 bool btc_get_device_type(const BD_ADDR bd_addr, int *p_device_type);
 
 void btc_config_lock(void);
index 44bdacfa007ea1f4907c5ea8478605f3c5bddb19..c9b76e3502fdf1ce9b644094cba4f1c533845982 100644 (file)
@@ -134,7 +134,7 @@ bool config_has_key(const config_t *config, const char *section, const char *key
     return (entry_find(config, section, key) != NULL);
 }
 
-bool config_has_key_in_section(config_t *config, char *key, char *key_value)
+bool config_has_key_in_section(config_t *config, const char *key, char *key_value)
 {
     LOG_DEBUG("key = %s, value = %s", key, key_value);
     for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) {
index 41f5ddb18a01290a81c2e84ba38fbb2ca78b870b..c1a2f3d5d6720d4061ff270e1c3b42de1619674c 100644 (file)
@@ -68,7 +68,7 @@ bool config_has_key(const config_t *config, const char *section, const char *key
 
 // Returns true if the config file has a key named |key| and the key_value.
 // Returns false otherwise. |config|, |key|, and |key_value| must not be NULL.
-bool config_has_key_in_section(config_t *config, char *key, char *key_value);
+bool config_has_key_in_section(config_t *config, const char *key, char *key_value);
 
 // Returns the integral value for a given |key| in |section|. If |section|
 // or |key| do not exist, or the value cannot be fully converted to an integer,
index dda360de23726251191b9102a88f5aa08f564214..9a02c526d7c1fdaed91c92d6bf60ceb827ffa742 100644 (file)
@@ -90,7 +90,7 @@ static tBTM_STATUS btm_sec_send_hci_disconnect (tBTM_SEC_DEV_REC *p_dev_rec, UIN
 UINT8           btm_sec_start_role_switch (tBTM_SEC_DEV_REC *p_dev_rec);
 tBTM_SEC_DEV_REC *btm_sec_find_dev_by_sec_state (UINT8 state);
 
-static BOOLEAN  btm_sec_set_security_level ( CONNECTION_TYPE conn_type, char *p_name, UINT8 service_id,
+static BOOLEAN  btm_sec_set_security_level ( CONNECTION_TYPE conn_type, const char *p_name, UINT8 service_id,
         UINT16 sec_level, UINT16 psm, UINT32 mx_proto_id,
         UINT32 mx_chan_id);
 #if (SMP_INCLUDED == TRUE)
@@ -459,7 +459,7 @@ void BTM_SetSecureConnectionsOnly (BOOLEAN secure_connections_only_mode)
 ** Returns          TRUE if registered OK, else FALSE
 **
 *******************************************************************************/
-BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, char *p_name, UINT8 service_id,
+BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, const char *p_name, UINT8 service_id,
                               UINT16 sec_level, UINT16 psm, UINT32 mx_proto_id,
                               UINT32 mx_chan_id)
 {
@@ -499,7 +499,7 @@ BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, char *p_name, UINT8 service
 ** Returns          TRUE if registered OK, else FALSE
 **
 *******************************************************************************/
-static BOOLEAN btm_sec_set_security_level (CONNECTION_TYPE conn_type, char *p_name, UINT8 service_id,
+static BOOLEAN btm_sec_set_security_level (CONNECTION_TYPE conn_type, const char *p_name, UINT8 service_id,
         UINT16 sec_level, UINT16 psm, UINT32 mx_proto_id,
         UINT32 mx_chan_id)
 {
index b685cdb7783a87f50c3aabdf1194bc960e35819a..113040b2fb668bd0bf2561d83fd85ef5b398ac7b 100644 (file)
@@ -3354,7 +3354,7 @@ void BTM_SetSecureConnectionsOnly (BOOLEAN secure_connections_only_mode);
 **
 *******************************************************************************/
 //extern
-BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, char *p_name,
+BOOLEAN BTM_SetSecurityLevel (BOOLEAN is_originator, const char *p_name,
                               UINT8 service_id, UINT16 sec_level,
                               UINT16 psm, UINT32 mx_proto_id,
                               UINT32 mx_chan_id);
index 86993b29e904f1b4008d05ee9bc1ecb7ae40f5a3..012188d7aba9eef3225881681ac24c340bb07df3 100644 (file)
@@ -9,3 +9,6 @@ COMPONENT_OBJS = libcoap/src/address.o libcoap/src/async.o libcoap/src/block.o l
 COMPONENT_SRCDIRS := libcoap/src libcoap port
 
 COMPONENT_SUBMODULES += libcoap
+
+libcoap/src/debug.o: CFLAGS += -Wno-write-strings
+libcoap/src/pdu.o: CFLAGS += -Wno-write-strings
index ed577c83aaa2c34a433248ad6dcb0fd7360e13e3..3fdda9068decec469c518660e6d6c996d2768e82 100644 (file)
@@ -4535,9 +4535,9 @@ static
 void arg_print_gnuswitch(FILE *fp, struct arg_hdr * *table)
 {
     int tabindex;
-    char *format1 = " -%c";
-    char *format2 = " [-%c";
-    char *suffix = "";
+    const char *format1 = " -%c";
+    const char *format2 = " [-%c";
+    const char *suffix = "";
 
     /* print all mandatory switches that are without argument values */
     for(tabindex = 0;
index 757725aad60d719244bd2225ced91af04b12e118..df04c91992e8043a3d335ede300f7e68d5133228 100644 (file)
@@ -66,7 +66,7 @@ static void ATTR_GDBFN gdbPacketChar(char c) {
 }
 
 //Send a string as part of a packet
-static void ATTR_GDBFN gdbPacketStr(char *c) {
+static void ATTR_GDBFN gdbPacketStr(const char *c) {
        while (*c!=0) {
                gdbPacketChar(*c);
                c++;
index 592cdfd8f2579718646e8c822eb0a6c081b60d12..7ab7fb2eb18bcca6b07de03d1e21c12665070562 100644 (file)
@@ -194,7 +194,7 @@ void test_fatfs_link_rename(const char* filename_prefix)
 
     FILE* f = fopen(name_src, "w+");
     TEST_ASSERT_NOT_NULL(f);
-    char* str = "0123456789";
+    const char* str = "0123456789";
     for (int i = 0; i < 4000; ++i) {
         TEST_ASSERT_NOT_EQUAL(EOF, fputs(str, f));
     }
index 36278502093a0e451ec1ba36cd74e900159127b9..2836fc3d2730c18fd4adb36cee0b94855ccc1814 100644 (file)
@@ -115,7 +115,7 @@ TEST_CASE("test asctime", "[newlib]")
     TEST_ASSERT_EQUAL_STRING(buf, time_str);
 }
 
-static bool fn_in_rom(void *fn, char *name)
+static bool fn_in_rom(void *fn, const char *name)
 {
     const int fnaddr = (int)fn;
     return (fnaddr >= 0x40000000) && (fnaddr < 0x40070000);
index 363cacdf8d08157f141e08b76f20f3236f55e163..6fc863aa76cb0747bc58da481603354a3697f201 100644 (file)
@@ -1106,9 +1106,9 @@ const char *SSL_rstate_string_long(SSL *ssl)
 /**
  * @brief get SSL statement string
  */
-char *SSL_state_string(const SSL *ssl)
+const char *SSL_state_string(const SSL *ssl)
 {
-    char *str = "UNKWN ";
+    const char *str = "UNKWN ";
 
     SSL_ASSERT2(ssl);
 
@@ -1214,9 +1214,9 @@ char *SSL_state_string(const SSL *ssl)
 /**
  * @brief get SSL statement long string
  */
-char *SSL_state_string_long(const SSL *ssl)
+const char *SSL_state_string_long(const SSL *ssl)
 {
-    char *str = "UNKWN ";
+    const char *str = "UNKWN ";
 
     SSL_ASSERT2(ssl);
 
index fdd3d241a6390bc6db46a82f586c4c52115c08f3..3805848b43cae19accd092fe2bc85429a109eb20 100644 (file)
@@ -158,7 +158,7 @@ void test_spiffs_rename(const char* filename_prefix)
 
     FILE* f = fopen(name_src, "w+");
     TEST_ASSERT_NOT_NULL(f);
-    char* str = "0123456789";
+    const char* str = "0123456789";
     for (int i = 0; i < 400; ++i) {
         TEST_ASSERT_NOT_EQUAL(EOF, fputs(str, f));
     }
index 17ad81f909abf748c2a5e79e9c7e7dc331e548a0..5294c344da9a2bd8dd4dc623abc23fca0666e1a7 100644 (file)
@@ -85,9 +85,9 @@ static struct gattc_profile_inst gl_profile_tab[PROFILE_NUM] = {
     },
 };
 
-static char *esp_key_type_to_str(esp_ble_key_type_t key_type)
+static const char *esp_key_type_to_str(esp_ble_key_type_t key_type)
 {
-   char *key_str = NULL;
+   const char *key_str = NULL;
    switch(key_type) {
     case ESP_LE_KEY_NONE:
         key_str = "ESP_LE_KEY_NONE";
index 3abfc5c5c7b73ca784d700d4ecc8ce8ce15311d7..4026db456232ce9e77ec747c5dd172a706500eae 100644 (file)
@@ -101,7 +101,7 @@ static ssize_t callback_recv(nghttp2_session *session, uint8_t *buf,
     return rv;
 }
 
-char *sh2lib_frame_type_str(int type)
+const char *sh2lib_frame_type_str(int type)
 {
     switch (type) {
     case NGHTTP2_HEADERS:
index 432bd6bc0c8e089df7556045045ea07074256397..a1dcaf588c5d6d371d2c762ea7ac5808a794cb26 100644 (file)
@@ -54,9 +54,9 @@ struct netif ppp_netif;
 static const char *TAG = "example";
 
 typedef struct {
-    char *cmd;
+    const char *cmd;
     uint16_t cmdSize;
-    char *cmdResponseOnOk;
+    const char *cmdResponseOnOk;
     uint32_t timeoutMs;
 } GSM_Cmd;