[Replicant] [libsamsung-ipc] [PATCH 19/21] tools: nv_data-imei: Fix unused result warning

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Fri Jun 17 16:15:51 UTC 2022


Without that fix, when running the following commands:
    $ cd tools
    $ makepkg
we have:
../../../tools/nv_data-imei.c: In function ‘write_imei’:
../../../tools/nv_data-imei.c:769:9: warning:
ignoring return value of ‘asprintf’
declared with attribute ‘warn_unused_result’ [-Wunused-result]
  769 |         asprintf(&md5_path, "%s.md5", nv_data_path);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 tools/nv_data-imei.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/nv_data-imei.c b/tools/nv_data-imei.c
index c710c8f..aa62e0c 100644
--- a/tools/nv_data-imei.c
+++ b/tools/nv_data-imei.c
@@ -766,7 +766,11 @@ int write_imei(char *nv_data_path, struct offset *offset,
 	assert(imei->imei);
 	assert(strlen(imei->imei) == IMEI_LENGTH);
 
-	asprintf(&md5_path, "%s.md5", nv_data_path);
+	rc = asprintf(&md5_path, "%s.md5", nv_data_path);
+	if (rc == -1) {
+		ipc_client_log(client, "%s: asprintf failed", __func__);
+		return -1;
+	}
 
 	/* We only support one device so far */
 	nv_data_secret = XMM616_NV_DATA_SECRET;
-- 
2.36.1



More information about the Replicant mailing list