* [PATCH] tools: env: fw_env: Fix unused-result warning
[not found] <CGME20221013084122epcas1p32a48d9dbebb95ff823161b9e6843541d@epcas1p3.samsung.com>
@ 2022-10-13 8:41 ` Jaehoon Chung
2022-12-08 20:23 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Jaehoon Chung @ 2022-10-13 8:41 UTC (permalink / raw)
To: u-boot; +Cc: rafal, Jaehoon Chung
Fix unused-result warning about fread.
tools/env/fw_env.c: In function ‘find_nvmem_device’:
tools/env/fw_env.c:1751:3: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
1751 | fread(buf, sizeof(buf), 1, fp);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
---
tools/env/fw_env.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index c251e2e6ba7d..c9a8774acefb 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -1733,6 +1733,7 @@ static int find_nvmem_device(void)
while (!nvmem && (dent = readdir(dir))) {
FILE *fp;
+ size_t size;
if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) {
continue;
@@ -1748,7 +1749,14 @@ static int find_nvmem_device(void)
continue;
}
- fread(buf, sizeof(buf), 1, fp);
+ size = fread(buf, sizeof(buf), 1, fp);
+ if (size != 1) {
+ fprintf(stderr,
+ "read failed about %s\n", comp);
+ fclose(fp);
+ return -EIO;
+ }
+
if (!strcmp(buf, "u-boot,env")) {
bytes = asprintf(&nvmem, "%s/%s/nvmem", path, dent->d_name);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tools: env: fw_env: Fix unused-result warning
2022-10-13 8:41 ` [PATCH] tools: env: fw_env: Fix unused-result warning Jaehoon Chung
@ 2022-12-08 20:23 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2022-12-08 20:23 UTC (permalink / raw)
To: Jaehoon Chung; +Cc: u-boot, rafal
[-- Attachment #1: Type: text/plain, Size: 507 bytes --]
On Thu, Oct 13, 2022 at 05:41:21PM +0900, Jaehoon Chung wrote:
> Fix unused-result warning about fread.
>
> tools/env/fw_env.c: In function ‘find_nvmem_device’:
> tools/env/fw_env.c:1751:3: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
> 1751 | fread(buf, sizeof(buf), 1, fp);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Applied to u-boot/next, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-08 20:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20221013084122epcas1p32a48d9dbebb95ff823161b9e6843541d@epcas1p3.samsung.com>
2022-10-13 8:41 ` [PATCH] tools: env: fw_env: Fix unused-result warning Jaehoon Chung
2022-12-08 20:23 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.