fix(nimble): Address few coverity reported issues

1. Overflowed constant (INTEGER_OVERFLOW): Added change to typecast
value
2. Structurally dead code: Removed dead code
3. Resource leak: Added a free for allocated memory, in case of failure
4. too_few_printf_args: Corrected print statement to pass arguments
5. Fixed nesting levels
6. Fixed unused value warnings
7. Illegal memory access fix
This commit is contained in:
Rahul Tank
2024-12-02 11:17:46 +05:30
parent 21fb91564e
commit 6e5a8865de
3 changed files with 4 additions and 2 deletions

View File

@@ -25,6 +25,7 @@ struct pkt_queue *pkt_queue_create(void)
}
if (osi_mutex_new(&queue->lock) != 0) {
osi_free(queue);
return NULL;
}
struct pkt_queue_header *p = &queue->header;
STAILQ_INIT(p);

View File

@@ -170,7 +170,7 @@ static esp_err_t set_config_service(void *config, const char *service_name, cons
/* XXX Does it even make any sense to set truncated mfg_data ? The
* only reason to not return failure from here is provisioning
* should continue as it is with error prints for mfg_data length */
mfg_data_len = MAX_BLE_MANUFACTURER_DATA_LEN - sizeof(ble_config->device_name) - 2;
mfg_data_len = (size_t)(MAX_BLE_MANUFACTURER_DATA_LEN - sizeof(ble_config->device_name) - 2);
}
ble_config->manufacturer_data = custom_manufacturer_data;
@@ -213,6 +213,7 @@ static esp_err_t set_config_endpoint(void *config, const char *endpoint_name, ui
realloc(ble_config->nu_lookup, (ble_config->nu_lookup_count + 1) * sizeof(protocomm_ble_name_uuid_t)));
if (!lookup_table) {
ESP_LOGE(TAG, "Error allocating memory for EP-UUID lookup table");
free(copy_ep_name);
return ESP_ERR_NO_MEM;
}