Resolve problems found by enabling -Wwrite-strings compilation flag

This commit is contained in:
Roland Dobai
2018-04-09 12:58:35 +02:00
parent 33480d1a2c
commit 744c2dcdd9
18 changed files with 30 additions and 27 deletions

View File

@@ -141,7 +141,7 @@ bool load_partition_table(bootloader_state_t* bs)
{ {
const esp_partition_info_t *partitions; const esp_partition_info_t *partitions;
const int ESP_PARTITION_TABLE_DATA_LEN = 0xC00; /* length of actual data (signature is appended to this) */ 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; esp_err_t err;
int num_partitions; 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, uint32_t inst = 0, pid = 0, stat = 0, data = 0, pc = 0,
lsstat = 0, lsaddr = 0, lsdata = 0, dstat = 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) { if (cpu == 0) {
stat = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_STATUS_REG); stat = DPORT_REG_READ(DPORT_PRO_CPU_RECORD_STATUS_REG);

View File

@@ -392,7 +392,7 @@ bool _btc_storage_compare_address_key_value(bt_bdaddr_t *remote_bd_addr,
{ {
bdstr_t bdstr; bdstr_t bdstr;
bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr)); bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
char *key_type_str; const char *key_type_str;
switch (key_type) { switch (key_type) {
case BTM_LE_KEY_PENC: case BTM_LE_KEY_PENC:
key_type_str = BTC_BLE_STORAGE_LE_KEY_PENC_STR; key_type_str = BTC_BLE_STORAGE_LE_KEY_PENC_STR;

View 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 osi_mutex_t lock; // protects operations on |config|.
static config_t *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); assert(key_value != NULL);
bool status = false; bool status = false;

View 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. // 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_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); bool btc_get_device_type(const BD_ADDR bd_addr, int *p_device_type);
void btc_config_lock(void); void btc_config_lock(void);

View 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); 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); 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)) { for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) {

View 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 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. // 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| // 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, // or |key| do not exist, or the value cannot be fully converted to an integer,

View 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); 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); 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, UINT16 sec_level, UINT16 psm, UINT32 mx_proto_id,
UINT32 mx_chan_id); UINT32 mx_chan_id);
#if (SMP_INCLUDED == TRUE) #if (SMP_INCLUDED == TRUE)
@@ -459,7 +459,7 @@ void BTM_SetSecureConnectionsOnly (BOOLEAN secure_connections_only_mode)
** Returns TRUE if registered OK, else FALSE ** 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, UINT16 sec_level, UINT16 psm, UINT32 mx_proto_id,
UINT32 mx_chan_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 ** 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, UINT16 sec_level, UINT16 psm, UINT32 mx_proto_id,
UINT32 mx_chan_id) UINT32 mx_chan_id)
{ {

View File

@@ -3354,7 +3354,7 @@ void BTM_SetSecureConnectionsOnly (BOOLEAN secure_connections_only_mode);
** **
*******************************************************************************/ *******************************************************************************/
//extern //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, UINT8 service_id, UINT16 sec_level,
UINT16 psm, UINT32 mx_proto_id, UINT16 psm, UINT32 mx_proto_id,
UINT32 mx_chan_id); UINT32 mx_chan_id);

View 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_SRCDIRS := libcoap/src libcoap port
COMPONENT_SUBMODULES += libcoap COMPONENT_SUBMODULES += libcoap
libcoap/src/debug.o: CFLAGS += -Wno-write-strings
libcoap/src/pdu.o: CFLAGS += -Wno-write-strings

View File

@@ -4535,9 +4535,9 @@ static
void arg_print_gnuswitch(FILE *fp, struct arg_hdr * *table) void arg_print_gnuswitch(FILE *fp, struct arg_hdr * *table)
{ {
int tabindex; int tabindex;
char *format1 = " -%c"; const char *format1 = " -%c";
char *format2 = " [-%c"; const char *format2 = " [-%c";
char *suffix = ""; const char *suffix = "";
/* print all mandatory switches that are without argument values */ /* print all mandatory switches that are without argument values */
for(tabindex = 0; for(tabindex = 0;

View File

@@ -66,7 +66,7 @@ static void ATTR_GDBFN gdbPacketChar(char c) {
} }
//Send a string as part of a packet //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) { while (*c!=0) {
gdbPacketChar(*c); gdbPacketChar(*c);
c++; c++;

View File

@@ -194,7 +194,7 @@ void test_fatfs_link_rename(const char* filename_prefix)
FILE* f = fopen(name_src, "w+"); FILE* f = fopen(name_src, "w+");
TEST_ASSERT_NOT_NULL(f); TEST_ASSERT_NOT_NULL(f);
char* str = "0123456789"; const char* str = "0123456789";
for (int i = 0; i < 4000; ++i) { for (int i = 0; i < 4000; ++i) {
TEST_ASSERT_NOT_EQUAL(EOF, fputs(str, f)); TEST_ASSERT_NOT_EQUAL(EOF, fputs(str, f));
} }

View File

@@ -115,7 +115,7 @@ TEST_CASE("test asctime", "[newlib]")
TEST_ASSERT_EQUAL_STRING(buf, time_str); 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; const int fnaddr = (int)fn;
return (fnaddr >= 0x40000000) && (fnaddr < 0x40070000); return (fnaddr >= 0x40000000) && (fnaddr < 0x40070000);

View File

@@ -1106,9 +1106,9 @@ const char *SSL_rstate_string_long(SSL *ssl)
/** /**
* @brief get SSL statement string * @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); SSL_ASSERT2(ssl);
@@ -1214,9 +1214,9 @@ char *SSL_state_string(const SSL *ssl)
/** /**
* @brief get SSL statement long string * @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); SSL_ASSERT2(ssl);

View File

@@ -158,7 +158,7 @@ void test_spiffs_rename(const char* filename_prefix)
FILE* f = fopen(name_src, "w+"); FILE* f = fopen(name_src, "w+");
TEST_ASSERT_NOT_NULL(f); TEST_ASSERT_NOT_NULL(f);
char* str = "0123456789"; const char* str = "0123456789";
for (int i = 0; i < 400; ++i) { for (int i = 0; i < 400; ++i) {
TEST_ASSERT_NOT_EQUAL(EOF, fputs(str, f)); TEST_ASSERT_NOT_EQUAL(EOF, fputs(str, f));
} }

View 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) { switch(key_type) {
case ESP_LE_KEY_NONE: case ESP_LE_KEY_NONE:
key_str = "ESP_LE_KEY_NONE"; key_str = "ESP_LE_KEY_NONE";

View File

@@ -101,7 +101,7 @@ static ssize_t callback_recv(nghttp2_session *session, uint8_t *buf,
return rv; return rv;
} }
char *sh2lib_frame_type_str(int type) const char *sh2lib_frame_type_str(int type)
{ {
switch (type) { switch (type) {
case NGHTTP2_HEADERS: case NGHTTP2_HEADERS:

View File

@@ -54,9 +54,9 @@ struct netif ppp_netif;
static const char *TAG = "example"; static const char *TAG = "example";
typedef struct { typedef struct {
char *cmd; const char *cmd;
uint16_t cmdSize; uint16_t cmdSize;
char *cmdResponseOnOk; const char *cmdResponseOnOk;
uint32_t timeoutMs; uint32_t timeoutMs;
} GSM_Cmd; } GSM_Cmd;