aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2022-06-14 16:11:20 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2022-06-26 02:11:32 +0200
commit2fd9bea7128d8ee43b4048552bc673c4cd4210e4 (patch)
treea2ec790c0944c6b3be63d74a81e09b1370c9b40b /samsung-ipc
parent8ce0431431a314c17af0a5809632e4d9c2042011 (diff)
downloadhardware_replicant_libsamsung-ipc-2fd9bea7128d8ee43b4048552bc673c4cd4210e4.tar.gz
hardware_replicant_libsamsung-ipc-2fd9bea7128d8ee43b4048552bc673c4cd4210e4.tar.bz2
hardware_replicant_libsamsung-ipc-2fd9bea7128d8ee43b4048552bc673c4cd4210e4.zip
partitions: android: test: remplace touch shell command
Without that fix, we have the following warning: ../../../../samsung-ipc/tests/partitions/android.c: In function ‘create_dummy_modem_image’: [...] ../../../../samsung-ipc/tests/partitions/android.c:53:9: warning: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 53 | system("touch /tmp/libsamsung-ipc.[...]/modem.img"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CCLD libsamsung-ipc-test Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Diffstat (limited to 'samsung-ipc')
-rw-r--r--samsung-ipc/tests/partitions/android.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/samsung-ipc/tests/partitions/android.c b/samsung-ipc/tests/partitions/android.c
index 45da72a..2314d2b 100644
--- a/samsung-ipc/tests/partitions/android.c
+++ b/samsung-ipc/tests/partitions/android.c
@@ -46,6 +46,7 @@ static char const * const dummy_modem_image_paths[] = {
int create_dummy_modem_image(struct ipc_client *client,
__attribute__((unused)) const char * const path)
{
+ int fd;
int rc;
rc = mkdir("/tmp/", 0755);
@@ -69,10 +70,26 @@ int create_dummy_modem_image(struct ipc_client *client,
}
}
- /* TODO: replace it by C code but make sure that the replacement code
- * is as robust as the shell commands
- */
- system("touch /tmp/libsamsung-ipc.55f4731d2e11e85bd889/modem.img");
+ fd = open("/tmp/libsamsung-ipc.55f4731d2e11e85bd889/modem.img",
+ O_CREAT, 0755);
+ if (fd == -1) {
+ rc = errno;
+ ipc_client_log(client,
+ "%s: open %s failed with error %d: %s",
+ __func__,
+ "/tmp/libsamsung-ipc.55f4731d2e11e85bd889/modem.img",
+ rc, strerror(rc));
+ }
+
+ rc = close(fd);
+ if (rc == -1) {
+ rc = errno;
+ ipc_client_log(client,
+ "%s: close %s failed with error %d: %s",
+ __func__,
+ "/tmp/libsamsung-ipc.55f4731d2e11e85bd889/modem.img",
+ rc, strerror(rc));
+ }
return 0;
}