mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ble_mesh: Fix compile error when -O2 (performance) is chosen
This commit is contained in:
parent
dd89b2dc0d
commit
a742255f8e
@ -268,7 +268,8 @@ esp_err_t esp_ble_mesh_provisioner_set_node_name(uint16_t index, const char *nam
|
||||
|
||||
arg.set_node_name.index = index;
|
||||
memset(arg.set_node_name.name, 0, sizeof(arg.set_node_name.name));
|
||||
memcpy(arg.set_node_name.name, name, strlen(name));
|
||||
strncpy(arg.set_node_name.name, name, ESP_BLE_MESH_NODE_NAME_MAX_LEN);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
@ -128,7 +128,8 @@ esp_err_t esp_ble_mesh_node_input_string(const char *string)
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_INPUT_STRING;
|
||||
memset(arg.input_string.string, 0, sizeof(arg.input_string.string));
|
||||
strncpy(arg.input_string.string, string, strlen(string));
|
||||
strncpy(arg.input_string.string, string,
|
||||
MIN(strlen(string), sizeof(arg.input_string.string)));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
@ -150,7 +151,8 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name)
|
||||
msg.act = BTC_BLE_MESH_ACT_SET_DEVICE_NAME;
|
||||
|
||||
memset(arg.set_device_name.name, 0, sizeof(arg.set_device_name.name));
|
||||
memcpy(arg.set_device_name.name, name, strlen(name));
|
||||
strncpy(arg.set_device_name.name, name, ESP_BLE_MESH_DEVICE_NAME_MAX_LEN);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -196,7 +198,8 @@ esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_INPUT_STR;
|
||||
|
||||
memset(arg.provisioner_input_str.string, 0, sizeof(arg.provisioner_input_str.string));
|
||||
strncpy(arg.provisioner_input_str.string, string, strlen(string));
|
||||
strncpy(arg.provisioner_input_str.string, string,
|
||||
MIN(strlen(string), sizeof(arg.provisioner_input_str.string)));
|
||||
arg.provisioner_input_str.link_idx = link_idx;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
|
@ -697,7 +697,7 @@ typedef struct {
|
||||
uint8_t dev_key[16]; /*!< Node device key */
|
||||
|
||||
/* Additional information */
|
||||
char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN]; /*!< Node name */
|
||||
char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN + 1]; /*!< Node name */
|
||||
uint16_t comp_length; /*!< Length of Composition Data */
|
||||
uint8_t *comp_data; /*!< Value of Composition Data */
|
||||
} __attribute__((packed)) esp_ble_mesh_node_t;
|
||||
|
@ -560,7 +560,8 @@ static int btc_ble_mesh_output_string_cb(const char *str)
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
strncpy(mesh_param.node_prov_output_str.string, str, strlen(str));
|
||||
strncpy(mesh_param.node_prov_output_str.string, str,
|
||||
MIN(strlen(str), sizeof(mesh_param.node_prov_output_str.string)));
|
||||
|
||||
ret = btc_ble_mesh_prov_callback(&mesh_param, ESP_BLE_MESH_NODE_PROV_OUTPUT_STRING_EVT);
|
||||
return (ret == BT_STATUS_SUCCESS) ? 0 : -1;
|
||||
|
@ -103,7 +103,7 @@ typedef union {
|
||||
char string[8];
|
||||
} input_string;
|
||||
struct ble_mesh_set_device_name_args {
|
||||
char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN];
|
||||
char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN + 1];
|
||||
} set_device_name;
|
||||
struct ble_mesh_provisioner_read_oob_pub_key_args {
|
||||
uint8_t link_idx;
|
||||
@ -157,7 +157,7 @@ typedef union {
|
||||
} set_primary_elem_addr;
|
||||
struct ble_mesh_provisioner_set_node_name_args {
|
||||
uint16_t index;
|
||||
char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN];
|
||||
char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN + 1];
|
||||
} set_node_name;
|
||||
struct ble_mesh_provisioner_add_local_app_key_args {
|
||||
uint8_t app_key[16];
|
||||
|
@ -490,6 +490,8 @@ int bt_mesh_provisioner_restore_node_name(u16_t addr, const char *name)
|
||||
}
|
||||
|
||||
strncpy(node->name, name, BLE_MESH_NODE_NAME_SIZE);
|
||||
node->name[BLE_MESH_NODE_NAME_SIZE] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -625,7 +627,7 @@ int bt_mesh_provisioner_set_node_name(u16_t index, const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
memset(mesh_nodes[index]->name, 0, BLE_MESH_NODE_NAME_SIZE);
|
||||
memset(mesh_nodes[index]->name, 0, sizeof(mesh_nodes[index]->name));
|
||||
strncpy(mesh_nodes[index]->name, name, length);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||
|
@ -42,7 +42,7 @@ struct bt_mesh_node {
|
||||
u8_t dev_key[16]; /* Node device key */
|
||||
|
||||
/* Additional information */
|
||||
char name[BLE_MESH_NODE_NAME_SIZE]; /* Node name */
|
||||
char name[BLE_MESH_NODE_NAME_SIZE + 1]; /* Node name */
|
||||
u16_t comp_length; /* Length of Composition Data */
|
||||
u8_t *comp_data; /* Value of Composition Data */
|
||||
} __packed;
|
||||
|
@ -109,7 +109,7 @@ static enum {
|
||||
MESH_GATT_PROXY,
|
||||
} gatt_svc = MESH_GATT_NONE;
|
||||
|
||||
static char device_name[DEVICE_NAME_SIZE] = "ESP-BLE-MESH";
|
||||
static char device_name[DEVICE_NAME_SIZE + 1] = "ESP-BLE-MESH";
|
||||
|
||||
int bt_mesh_set_device_name(const char *name)
|
||||
{
|
||||
@ -124,7 +124,7 @@ int bt_mesh_set_device_name(const char *name)
|
||||
}
|
||||
|
||||
memset(device_name, 0x0, sizeof(device_name));
|
||||
memcpy(device_name, name, strlen(name));
|
||||
strncpy(device_name, name, DEVICE_NAME_SIZE);
|
||||
|
||||
return bt_mesh_gatts_set_local_device_name(device_name);
|
||||
}
|
||||
|
@ -1081,7 +1081,7 @@ static int node_info_set(u16_t addr, bool *exist)
|
||||
|
||||
static int node_name_set(u16_t addr)
|
||||
{
|
||||
char name[BLE_MESH_NODE_NAME_SIZE] = {0};
|
||||
char name[BLE_MESH_NODE_NAME_SIZE + 1] = {0};
|
||||
char get[16] = {'\0'};
|
||||
bool exist = false;
|
||||
int err = 0;
|
||||
@ -2513,7 +2513,7 @@ void bt_mesh_clear_node_info(u16_t unicast_addr)
|
||||
|
||||
void bt_mesh_store_node_name(struct bt_mesh_node *node)
|
||||
{
|
||||
char node_name[BLE_MESH_NODE_NAME_SIZE] = {0};
|
||||
char node_name[BLE_MESH_NODE_NAME_SIZE + 1] = {0};
|
||||
char name[16] = {'\0'};
|
||||
int err = 0;
|
||||
|
||||
@ -2522,7 +2522,7 @@ void bt_mesh_store_node_name(struct bt_mesh_node *node)
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(node_name, node->name, BLE_MESH_NODE_NAME_SIZE);
|
||||
strncpy(node_name, node->name, BLE_MESH_NODE_NAME_SIZE + 1);
|
||||
|
||||
sprintf(name, "mesh/pn/%04x/n", node->unicast_addr);
|
||||
err = bt_mesh_save_core_settings(name, (const u8_t *)node_name, BLE_MESH_NODE_NAME_SIZE);
|
||||
|
@ -138,7 +138,7 @@ static void provisioner_prov_complete(int node_index, const uint8_t uuid[16], ui
|
||||
uint8_t elem_num, uint16_t net_idx)
|
||||
{
|
||||
example_node_info_t *node = NULL;
|
||||
char name[10];
|
||||
char name[11] = {0};
|
||||
esp_err_t err;
|
||||
|
||||
ESP_LOGI(TAG, "Node index: 0x%x, unicast address: 0x%02x, element num: %d, netkey index: 0x%02x",
|
||||
|
@ -191,7 +191,7 @@ static esp_err_t prov_complete(int node_idx, const esp_ble_mesh_octet16_t uuid,
|
||||
esp_ble_mesh_client_common_param_t common = {0};
|
||||
esp_ble_mesh_cfg_client_get_state_t get_state = {0};
|
||||
esp_ble_mesh_node_info_t *node = NULL;
|
||||
char name[10];
|
||||
char name[11] = {0};
|
||||
int err;
|
||||
|
||||
ESP_LOGI(TAG, "node index: 0x%x, unicast address: 0x%02x, element num: %d, netkey index: 0x%02x",
|
||||
|
Loading…
x
Reference in New Issue
Block a user