[Replicant] [libsamsung-ipc] [PATCH 18/21] xmm626_kernel_smdk4412_gprs_get_iface: handle asprintf errors

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


Without that fix we have the following warning:
    CC       modems/xmm626/xmm626_kernel_smdk4412.lo
    ../../../samsung-ipc/modems/xmm626/xmm626_kernel_smdk4412.c:
    In function 'xmm626_kernel_smdk4412_gprs_get_iface':
    ../../../samsung-ipc/modems/xmm626/xmm626_kernel_smdk4412.c:589:9:
    warning: ignoring return value of 'asprintf' declared with attribute
    'warn_unused_result' [-Wunused-result]
    589 | asprintf(&iface, "%s%d", XMM626_[...]_IFACE_PREFIX, cid - 1);
        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    CC       modems/xmm626/xmm626_mipi.lo

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 samsung-ipc/modems/xmm626/xmm626_kernel_smdk4412.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/samsung-ipc/modems/xmm626/xmm626_kernel_smdk4412.c b/samsung-ipc/modems/xmm626/xmm626_kernel_smdk4412.c
index c6b1578..a8de89c 100644
--- a/samsung-ipc/modems/xmm626/xmm626_kernel_smdk4412.c
+++ b/samsung-ipc/modems/xmm626/xmm626_kernel_smdk4412.c
@@ -582,11 +582,17 @@ char *xmm626_kernel_smdk4412_gprs_get_iface(
 	__attribute__((unused)) struct ipc_client *client, unsigned int cid)
 {
 	char *iface = NULL;
+	int rc;
 
 	if (cid > XMM626_SEC_MODEM_GPRS_IFACE_COUNT)
 		return NULL;
 
-	asprintf(&iface, "%s%d", XMM626_SEC_MODEM_GPRS_IFACE_PREFIX, cid - 1);
+	rc = asprintf(&iface, "%s%d",
+		      XMM626_SEC_MODEM_GPRS_IFACE_PREFIX, cid - 1);
+	if (rc == -1) {
+		ipc_client_log(client, "%s: asprintf failed", __func__);
+		return NULL;
+	}
 
 	return iface;
 }
-- 
2.36.1



More information about the Replicant mailing list