Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applications: Audio: Resolved coverity issues #18795

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion applications/nrf5340_audio/src/modules/lc3_streamer.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ struct lc3_stream {
};

static struct lc3_stream streams[CONFIG_SD_CARD_LC3_STREAMER_MAX_NUM_STREAMS];
#if (CONFIG_SD_CARD_LC3_STREAMER_MAX_NUM_STREAMS > UINT8_MAX)
#error "CONFIG_SD_CARD_LC3_STREAMER_MAX_NUM_STREAMS is larger than UINT8_MAX"
#endif

static bool initialized;

Expand Down Expand Up @@ -353,7 +356,7 @@ int lc3_streamer_stream_register(const char *const filename, uint8_t *const stre

bool free_slot_found = false;

for (int i = 0; i < ARRAY_SIZE(streams); i++) {
for (uint8_t i = 0; i < ARRAY_SIZE(streams); i++) {
if (streams[i].state == STREAM_IDLE) {
LOG_DBG("Found free stream slot %d", i);
*streamer_idx = i;
Expand Down
10 changes: 5 additions & 5 deletions applications/nrf5340_audio/src/modules/sd_card.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ int sd_card_list_files(char const *const path, char *buf, size_t *buf_size, bool
return ret;
}
} else {
if (strlen(path) > CONFIG_FS_FATFS_MAX_LFN) {
if (strlen(path) > PATH_MAX_LEN) {
LOG_ERR("Path is too long");
return -FR_INVALID_NAME;
}
Expand Down Expand Up @@ -290,7 +290,7 @@ int sd_card_open_write_close(char const *const filename, char const *const data,
return -ENODEV;
}

if (strlen(filename) > CONFIG_FS_FATFS_MAX_LFN) {
if (strlen(filename) > PATH_MAX_LEN) {
LOG_ERR("Filename is too long");
return -ENAMETOOLONG;
}
Expand Down Expand Up @@ -338,7 +338,7 @@ int sd_card_open_read_close(char const *const filename, char *const buf, size_t
return -ENODEV;
}

if (strlen(filename) > CONFIG_FS_FATFS_MAX_LFN) {
if (strlen(filename) > PATH_MAX_LEN) {
LOG_ERR("Filename is too long");
return -FR_INVALID_NAME;
}
Expand Down Expand Up @@ -376,7 +376,7 @@ int sd_card_open(char const *const filename, struct fs_file_t *f_seg_read_entry)
{
int ret;
char abs_path_name[PATH_MAX_LEN + 1] = SD_ROOT_PATH;
size_t avilable_path_space = PATH_MAX_LEN - strlen(SD_ROOT_PATH);
size_t available_path_space = PATH_MAX_LEN - strlen(SD_ROOT_PATH);

if (!sd_init_success) {
return -ENODEV;
Expand All @@ -392,7 +392,7 @@ int sd_card_open(char const *const filename, struct fs_file_t *f_seg_read_entry)
return -EINVAL;
}

strncat(abs_path_name, filename, avilable_path_space);
strncat(abs_path_name, filename, available_path_space);

LOG_INF("abs path name:\t%s", abs_path_name);

Expand Down
Loading