[Replicant] [libsamsung-ipc] [PATCH 13/21] partitions: android: test: remplace mkdir shell command

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


Without that fix, we have the following warning:
      CC       partitions/android.o
    ../../../../samsung-ipc/tests/partitions/android.c:
    In function ‘create_dummy_modem_image’:
    ../../../../samsung-ipc/tests/partitions/android.c:52:9: warning:
    ignoring return value of ‘system’ declared with attribute
    ‘warn_unused_result’ [-Wunused-result]
       52 | system("mkdir -p /tmp/libsamsung-ipc.55f4731d2e11e85bd889/");
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 samsung-ipc/tests/partitions/android.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/samsung-ipc/tests/partitions/android.c b/samsung-ipc/tests/partitions/android.c
index 708480a..45da72a 100644
--- a/samsung-ipc/tests/partitions/android.c
+++ b/samsung-ipc/tests/partitions/android.c
@@ -43,13 +43,35 @@ static char const * const dummy_modem_image_paths[] = {
 };
 
 
-int create_dummy_modem_image(__attribute__((unused)) struct ipc_client *client,
+int create_dummy_modem_image(struct ipc_client *client,
 			     __attribute__((unused)) const char * const path)
 {
+	int rc;
+
+	rc = mkdir("/tmp/", 0755);
+	if (rc == -1) {
+		rc = errno;
+		if (rc != EEXIST)
+			ipc_client_log(client,
+				       "%s: mkdir %s failed with error %d: %s",
+				       __func__, "/tmp/", rc, strerror(rc));
+	}
+
+	rc = mkdir("/tmp/libsamsung-ipc.55f4731d2e11e85bd889/", 0755);
+	if (rc == -1) {
+		rc = errno;
+		if (rc != EEXIST) {
+			ipc_client_log(client,
+				       "%s: mkdir %s failed with error %d: %s",
+				       __func__,
+				       "/tmp/libsamsung-ipc.55f4731d2e11e85bd889/",
+				       rc, strerror(rc));
+		}
+	}
+
 	/* TODO: replace it by C code but make sure that the replacement code
 	 * is as robust as the shell commands
 	 */
-	system("mkdir -p /tmp/libsamsung-ipc.55f4731d2e11e85bd889/");
 	system("touch /tmp/libsamsung-ipc.55f4731d2e11e85bd889/modem.img");
 
 	return 0;
-- 
2.36.1



More information about the Replicant mailing list