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 <gnu...@cyberdimension.org> --- samsung-ipc/tests/partitions/android.c | 25 +++++++++++++++++++++---- 1 file 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; } -- 2.36.1 _______________________________________________ Replicant mailing list Replicant@osuosl.org https://lists.osuosl.org/mailman/listinfo/replicant