logger: Log fread error only when it happened

fread may return 0 when some error occurred or nothig has been reded.
Moreover errno may not be set on Windows plaform, use ferror
instead. See:
https://www.gnu.org/software/gnulib/manual/html_node/fread.html

Fixes: 337afc4f3809: ("logger: add error message when reading sof/etrace instead of sof/trace")

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
This commit is contained in:
Karol Trzcinski 2020-09-24 13:35:10 +02:00 committed by Liam Girdwood
parent d477a83aaa
commit 5eb9c49258
1 changed files with 6 additions and 4 deletions

View File

@ -640,10 +640,12 @@ static int logger_read(void)
return -errno;
}
}
log_err("in %s(), fread(..., %s) failed: %s(%d)\n",
__func__, global_config->in_file,
strerror(errno), errno);
return -errno;
ret = -ferror(global_config->in_fd);
if (ret)
log_err("in %s(), fread(..., %s) failed: %s(%d)\n",
__func__, global_config->in_file,
strerror(-ret), ret);
return ret;
}
/* checking if received trace address is located in