Skip to content

Commit

Permalink
smec: ldc: check fwrite status
Browse files Browse the repository at this point in the history
Check fwrite status for error

Signed-off-by: Adrian Bonislawski <[email protected]>
  • Loading branch information
abonislawski committed Nov 28, 2023
1 parent 5de8e76 commit a98146b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions smex/ldc.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,13 @@ static int write_logs_dictionary(struct image *image,
header.base_address = section->vaddr;
header.data_length = section->size;

fwrite(&header, sizeof(struct snd_sof_logs_header), 1,
image->ldc_out_fd);
count = fwrite(&header, sizeof(struct snd_sof_logs_header), 1,
image->ldc_out_fd);
if (count != 1) {
fprintf(stderr, "error: can't write header\n");
ret = -errno;
goto out;
}

count = fwrite(buffer, 1, section->size, image->ldc_out_fd);
if (count != section->size) {
Expand Down Expand Up @@ -140,8 +145,12 @@ static int write_uids_dictionary(struct image *image,
header.base_address = section->vaddr;
header.data_length = section->size;

fwrite(&header, sizeof(struct snd_sof_uids_header), 1,
image->ldc_out_fd);
if (fwrite(&header, sizeof(struct snd_sof_uids_header), 1,
image->ldc_out_fd) != 1) {
fprintf(stderr, "error: cant't write header\n");
ret = -errno;
goto out;
}

if (fwrite(buffer, 1, section->size, image->ldc_out_fd) !=
section->size) {
Expand Down

0 comments on commit a98146b

Please sign in to comment.