From: Sughosh Ganu <sughosh.ganu@linaro.org>
Date: Fri, 22 Mar 2024 10:57:15 +0000 (+0530)
Subject: tools: mkfwumdata: fix the size parameter to the fwrite call
X-Git-Tag: v2025.01-rc5-pxa1908~398^2~82^2~18
X-Git-Url: http://git.dujemihanovic.xyz/img/html/static/%7B%7B?a=commitdiff_plain;h=d99127a69ebf65cd35c33896ea6f4b45b77b8c82;p=u-boot.git

tools: mkfwumdata: fix the size parameter to the fwrite call

The fwrite call returns the number of bytes transferred as part of the
write only when the size parameter is 1. Pass the size parameter to
the library call as 1 so that the correct number of bytes transferred
are returned.

Fixes: fdd56bfd3ad ("tools: Add mkfwumdata tool for FWU metadata image")
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Tested-by: Michal Simek <michal.simek@amd.com>
---

diff --git a/tools/mkfwumdata.c b/tools/mkfwumdata.c
index 9732a8ddc5..b2d90ca7c9 100644
--- a/tools/mkfwumdata.c
+++ b/tools/mkfwumdata.c
@@ -259,7 +259,7 @@ fwu_make_mdata(size_t images, size_t banks, char *uuids[], char *output)
 		goto done_make;
 	}
 
-	ret = fwrite(mobj->mdata, mobj->size, 1, file);
+	ret = fwrite(mobj->mdata, 1, mobj->size, file);
 	if (ret != mobj->size)
 		ret = -errno;
 	else