mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 05:34:32 +02:00
fix(driver): issues reported by coverity
This commit is contained in:
@@ -44,7 +44,9 @@ static void IRAM_ATTR esp_cam_ctlr_dvp_config_dma_desc(esp_cam_ctlr_dvp_dma_desc
|
|||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
desc[n - 1].next = NULL;
|
if (n > 0) {
|
||||||
|
desc[n - 1].next = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -130,10 +130,10 @@ esp_err_t jpeg_parse_sof_marker(jpeg_dec_header_info_t *header_info)
|
|||||||
|
|
||||||
// The vertical and horizontal in process must be divided by mcu block.
|
// The vertical and horizontal in process must be divided by mcu block.
|
||||||
if (header_info->origin_v % header_info->mcuy != 0) {
|
if (header_info->origin_v % header_info->mcuy != 0) {
|
||||||
header_info->process_v = (uint32_t)(ceil(header_info->origin_v / header_info->mcuy) + 1) * header_info->mcuy;
|
header_info->process_v = ((header_info->origin_v / header_info->mcuy) + 1) * header_info->mcuy;
|
||||||
}
|
}
|
||||||
if (header_info->origin_h % header_info->mcux != 0) {
|
if (header_info->origin_h % header_info->mcux != 0) {
|
||||||
header_info->process_h = (uint32_t)(ceil(header_info->origin_h / header_info->mcux) + 1) * header_info->mcux;
|
header_info->process_h = ((header_info->origin_h / header_info->mcux) + 1) * header_info->mcux;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
@@ -138,7 +138,9 @@ static IRAM_ATTR size_t s_parlio_mount_transaction_buffer(parlio_rx_unit_handle_
|
|||||||
/* Update the current transaction to the next one, and declare the delimiter is under using of the rx unit */
|
/* Update the current transaction to the next one, and declare the delimiter is under using of the rx unit */
|
||||||
memcpy(&rx_unit->curr_trans, trans, sizeof(parlio_rx_transaction_t));
|
memcpy(&rx_unit->curr_trans, trans, sizeof(parlio_rx_transaction_t));
|
||||||
portENTER_CRITICAL_SAFE(&s_rx_spinlock);
|
portENTER_CRITICAL_SAFE(&s_rx_spinlock);
|
||||||
trans->delimiter->under_using = true;
|
if (trans->delimiter) {
|
||||||
|
trans->delimiter->under_using = true;
|
||||||
|
}
|
||||||
portEXIT_CRITICAL_SAFE(&s_rx_spinlock);
|
portEXIT_CRITICAL_SAFE(&s_rx_spinlock);
|
||||||
|
|
||||||
uint32_t desc_num = trans->size / PARLIO_MAX_ALIGNED_DMA_BUF_SIZE;
|
uint32_t desc_num = trans->size / PARLIO_MAX_ALIGNED_DMA_BUF_SIZE;
|
||||||
|
@@ -215,7 +215,7 @@ static int uart_rx_char(int fd)
|
|||||||
static int uart_rx_char_via_driver(int fd)
|
static int uart_rx_char_via_driver(int fd)
|
||||||
{
|
{
|
||||||
uint8_t c;
|
uint8_t c;
|
||||||
int timeout = s_ctx[fd]->non_blocking ? 0 : portMAX_DELAY;
|
TickType_t timeout = s_ctx[fd]->non_blocking ? 0 : portMAX_DELAY;
|
||||||
int n = uart_read_bytes(fd, &c, 1, timeout);
|
int n = uart_read_bytes(fd, &c, 1, timeout);
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
return NONE;
|
return NONE;
|
||||||
|
@@ -15,10 +15,12 @@
|
|||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
#include "soc/debug_probe_periph.h"
|
#include "soc/debug_probe_periph.h"
|
||||||
|
#include "soc/io_mux_reg.h"
|
||||||
#include "hal/debug_probe_ll.h"
|
#include "hal/debug_probe_ll.h"
|
||||||
#include "esp_private/debug_probe.h"
|
#include "esp_private/debug_probe.h"
|
||||||
|
#include "esp_private/gpio.h"
|
||||||
|
#include "esp_private/esp_gpio_reserve.h"
|
||||||
#include "esp_rom_gpio.h"
|
#include "esp_rom_gpio.h"
|
||||||
#include "driver/gpio.h"
|
|
||||||
|
|
||||||
static const char *TAG = "dbg_probe";
|
static const char *TAG = "dbg_probe";
|
||||||
|
|
||||||
@@ -28,6 +30,7 @@ typedef struct debug_probe_channel_t debug_probe_channel_t;
|
|||||||
struct debug_probe_unit_t {
|
struct debug_probe_unit_t {
|
||||||
int unit_id; // unit id
|
int unit_id; // unit id
|
||||||
debug_probe_channel_t *channels[DEBUG_PROBE_LL_CHANNELS_PER_UNIT]; // channels installed in this unit
|
debug_probe_channel_t *channels[DEBUG_PROBE_LL_CHANNELS_PER_UNIT]; // channels installed in this unit
|
||||||
|
uint64_t pin_bit_mask; // bit-mask of the GPIOs used by this unit
|
||||||
};
|
};
|
||||||
|
|
||||||
struct debug_probe_channel_t {
|
struct debug_probe_channel_t {
|
||||||
@@ -53,6 +56,7 @@ static esp_err_t debug_probe_unit_destroy(debug_probe_unit_t *unit)
|
|||||||
|
|
||||||
// disable the probe output
|
// disable the probe output
|
||||||
debug_probe_ll_enable_unit(unit_id, false);
|
debug_probe_ll_enable_unit(unit_id, false);
|
||||||
|
esp_gpio_revoke(unit->pin_bit_mask);
|
||||||
// free the memory
|
// free the memory
|
||||||
free(unit);
|
free(unit);
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
@@ -60,7 +64,6 @@ static esp_err_t debug_probe_unit_destroy(debug_probe_unit_t *unit)
|
|||||||
|
|
||||||
esp_err_t debug_probe_new_unit(const debug_probe_unit_config_t *config, debug_probe_unit_handle_t *out_handle)
|
esp_err_t debug_probe_new_unit(const debug_probe_unit_config_t *config, debug_probe_unit_handle_t *out_handle)
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
|
||||||
debug_probe_unit_t *unit = NULL;
|
debug_probe_unit_t *unit = NULL;
|
||||||
int unit_id = -1;
|
int unit_id = -1;
|
||||||
ESP_RETURN_ON_FALSE(config && out_handle, ESP_ERR_INVALID_ARG, TAG, "invalid args");
|
ESP_RETURN_ON_FALSE(config && out_handle, ESP_ERR_INVALID_ARG, TAG, "invalid args");
|
||||||
@@ -80,43 +83,35 @@ esp_err_t debug_probe_new_unit(const debug_probe_unit_config_t *config, debug_pr
|
|||||||
ESP_RETURN_ON_FALSE(unit, ESP_ERR_NO_MEM, TAG, "no mem for unit");
|
ESP_RETURN_ON_FALSE(unit, ESP_ERR_NO_MEM, TAG, "no mem for unit");
|
||||||
unit->unit_id = unit_id;
|
unit->unit_id = unit_id;
|
||||||
|
|
||||||
// configure the GPIOs
|
uint64_t pin_bit_mask = 0;
|
||||||
gpio_config_t monitor_io_conf = {
|
|
||||||
.mode = GPIO_MODE_OUTPUT,
|
|
||||||
.pin_bit_mask = 0,
|
|
||||||
};
|
|
||||||
for (int i = 0; i < SOC_DEBUG_PROBE_MAX_OUTPUT_WIDTH; i++) {
|
for (int i = 0; i < SOC_DEBUG_PROBE_MAX_OUTPUT_WIDTH; i++) {
|
||||||
// skip unused IOs
|
if (config->probe_out_gpio_nums[i] >= 0) {
|
||||||
if (config->probe_out_gpio_nums[i] < 0) {
|
pin_bit_mask |= BIT64(config->probe_out_gpio_nums[i]);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
monitor_io_conf.pin_bit_mask |= (1ULL << config->probe_out_gpio_nums[i]);
|
|
||||||
}
|
}
|
||||||
if (monitor_io_conf.pin_bit_mask) {
|
// reserve the GPIO output path, because we don't expect another peripheral to signal to the same GPIO
|
||||||
ESP_GOTO_ON_ERROR(gpio_config(&monitor_io_conf), err, TAG, "gpio_config failed");
|
uint64_t old_gpio_rsv_mask = esp_gpio_reserve(pin_bit_mask);
|
||||||
|
// check if the GPIO is already used by others, RMT TX channel only uses the output path of the GPIO
|
||||||
|
if (old_gpio_rsv_mask & pin_bit_mask) {
|
||||||
|
ESP_LOGW(TAG, "GPIO conflict with others");
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect the probe output signals to the GPIOs
|
// connect the probe output signals to the GPIOs
|
||||||
for (int i = 0; i < SOC_DEBUG_PROBE_MAX_OUTPUT_WIDTH; i++) {
|
for (int i = 0; i < SOC_DEBUG_PROBE_MAX_OUTPUT_WIDTH; i++) {
|
||||||
if (config->probe_out_gpio_nums[i] < 0) {
|
if (config->probe_out_gpio_nums[i] >= 0) {
|
||||||
continue;
|
gpio_func_sel(config->probe_out_gpio_nums[i], PIN_FUNC_GPIO);
|
||||||
|
esp_rom_gpio_connect_out_signal(config->probe_out_gpio_nums[i],
|
||||||
|
debug_probe_periph_signals.units[unit_id].out_sig[i],
|
||||||
|
false, false);
|
||||||
}
|
}
|
||||||
esp_rom_gpio_connect_out_signal(config->probe_out_gpio_nums[i],
|
|
||||||
debug_probe_periph_signals.units[unit_id].out_sig[i],
|
|
||||||
false, false);
|
|
||||||
}
|
}
|
||||||
|
unit->pin_bit_mask = pin_bit_mask;
|
||||||
|
|
||||||
// enable the probe unit
|
// enable the probe unit
|
||||||
debug_probe_ll_enable_unit(unit_id, true);
|
debug_probe_ll_enable_unit(unit_id, true);
|
||||||
|
|
||||||
*out_handle = unit;
|
*out_handle = unit;
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
|
||||||
err:
|
|
||||||
if (unit) {
|
|
||||||
debug_probe_unit_destroy(unit);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t debug_probe_del_unit(debug_probe_unit_handle_t unit)
|
esp_err_t debug_probe_del_unit(debug_probe_unit_handle_t unit)
|
||||||
|
Reference in New Issue
Block a user