[LTP] [PATCH v3 3/3] syscalls/shmget*: Convert into new api

Cyril Hrubis chrubis@suse.cz
Mon Jun 28 17:05:05 CEST 2021


Hi!
Pushed with a minor changes, thanks.

diff --git a/testcases/kernel/syscalls/ipc/shmget/shmget03.c b/testcases/kernel/syscalls/ipc/shmget/shmget03.c
index 81841788c..efbc465e1 100644
--- a/testcases/kernel/syscalls/ipc/shmget/shmget03.c
+++ b/testcases/kernel/syscalls/ipc/shmget/shmget03.c
@@ -41,7 +41,6 @@ static void setup(void)
 
        queues = SAFE_MALLOC(maxshms * sizeof(int));
        for (num = 0; num < maxshms; num++) {
-               queues[num] = -1;
                res = shmget(shmkey + num, SHM_SIZE, IPC_CREAT | IPC_EXCL | SHM_RW);
                if (res == -1)
                        tst_brk(TBROK | TERRNO, "shmget failed unexpectedly");
@@ -59,10 +58,8 @@ static void cleanup(void)
        if (!queues)
                return;
 
-       for (num = 0; num < queue_cnt; num++) {
-               if (queues[num] != -1)
-                       SAFE_SHMCTL(queues[num], IPC_RMID, NULL);
-       }
+       for (num = 0; num < queue_cnt; num++)
+               SAFE_SHMCTL(queues[num], IPC_RMID, NULL);
 
        free(queues);
 }

As there is no need to check for -1 and pre-initialize the array
anymore.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list