All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] futex_waitv03: cleanup shms
@ 2022-03-24 23:49 Chunyu Hu
  2022-03-25  7:17 ` Li Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Chunyu Hu @ 2022-03-24 23:49 UTC (permalink / raw)
  To: ltp

cleanup all the created shms, otherwise, it would be left in sys as
gubbage (ipcs show).

Signed-off-by: Chunyu Hu <chuhu@redhat.com>
---
 testcases/kernel/syscalls/futex/futex_waitv03.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/futex/futex_waitv03.c b/testcases/kernel/syscalls/futex/futex_waitv03.c
index d8e39c76a..1f53addac 100644
--- a/testcases/kernel/syscalls/futex/futex_waitv03.c
+++ b/testcases/kernel/syscalls/futex/futex_waitv03.c
@@ -26,11 +26,11 @@ static char *str_numfutex;
 static int numfutex = 30;
 
 static struct futex_waitv *waitv;
+static int *shmids;
 
 static void setup(void)
 {
 	struct futex_test_variants tv = futex_variant();
-	int shm_id;
 	int i;
 
 	tst_res(TINFO, "Testing variant: %s", tv.desc);
@@ -41,10 +41,12 @@ static void setup(void)
 
 	waitv = tst_alloc(sizeof(struct futex_waitv) * numfutex);
 	memset(waitv, 0, sizeof(struct futex_waitv) * numfutex);
+	shmids = tst_alloc(sizeof(int*) * numfutex);
+	memset(shmids, 0, sizeof(int*) * numfutex);
 
 	for (i = 0; i < numfutex; i++) {
-		shm_id = SAFE_SHMGET(IPC_PRIVATE, 4096, IPC_CREAT | 0666);
-		waitv[i].uaddr = (uintptr_t)SAFE_SHMAT(shm_id, NULL, 0);
+		shmids[i] = SAFE_SHMGET(IPC_PRIVATE, 4096, IPC_CREAT | 0666);
+		waitv[i].uaddr = (uintptr_t)SAFE_SHMAT(shmids[i], NULL, 0);
 		waitv[i].flags = FUTEX_32;
 		waitv[i].val = 0;
 	}
@@ -59,6 +61,7 @@ static void cleanup(void)
 			continue;
 
 		SAFE_SHMDT((void *)(uintptr_t)waitv[i].uaddr);
+		SAFE_SHMCTL(shmids[i], IPC_RMID, NULL);
 	}
 }
 
-- 
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] [PATCH] futex_waitv03: cleanup shms
  2022-03-24 23:49 [LTP] [PATCH] futex_waitv03: cleanup shms Chunyu Hu
@ 2022-03-25  7:17 ` Li Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Li Wang @ 2022-03-25  7:17 UTC (permalink / raw)
  To: Chunyu Hu; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 64 bytes --]

Reviewed-by: Li Wang <liwang@redhat.com>


-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 455 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-25  7:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24 23:49 [LTP] [PATCH] futex_waitv03: cleanup shms Chunyu Hu
2022-03-25  7:17 ` Li Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.