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 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);

View 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;

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 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;

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.
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);

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);
}
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)) {

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 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,

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);
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)
{

View 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);

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_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)
{
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;

View 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++;

View 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));
}

View 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);

View 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);

View 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));
}

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) {
case 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;
}
char *sh2lib_frame_type_str(int type)
const char *sh2lib_frame_type_str(int type)
{
switch (type) {
case NGHTTP2_HEADERS:

View 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;