smex: ldc: check fwrite status

Check fwrite status for error

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
This commit is contained in:
Adrian Bonislawski 2023-11-28 08:31:43 +01:00 committed by Kai Vehmanen
parent 17c226b683
commit c1bd155f43
1 changed files with 13 additions and 4 deletions

View File

@ -98,8 +98,13 @@ static int write_logs_dictionary(struct image *image,
header.base_address = section->vaddr; header.base_address = section->vaddr;
header.data_length = section->size; header.data_length = section->size;
fwrite(&header, sizeof(struct snd_sof_logs_header), 1, count = fwrite(&header, sizeof(struct snd_sof_logs_header), 1,
image->ldc_out_fd); 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); count = fwrite(buffer, 1, section->size, image->ldc_out_fd);
if (count != section->size) { if (count != section->size) {
@ -140,8 +145,12 @@ static int write_uids_dictionary(struct image *image,
header.base_address = section->vaddr; header.base_address = section->vaddr;
header.data_length = section->size; header.data_length = section->size;
fwrite(&header, sizeof(struct snd_sof_uids_header), 1, if (fwrite(&header, sizeof(struct snd_sof_uids_header), 1,
image->ldc_out_fd); 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) != if (fwrite(buffer, 1, section->size, image->ldc_out_fd) !=
section->size) { section->size) {