public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Samir <samir@linux.ibm.com>
To: ltp@lists.linux.it
Cc: Samir <samir@linux.ibm.com>
Subject: [LTP] [PATCH v2] mem/hugetlb: use SAFE_SHMGET() in hugeshmget setup function.
Date: Sun, 12 Apr 2026 16:10:39 +0200	[thread overview]
Message-ID: <20260412141039.1075095-1-samir@linux.ibm.com> (raw)

I updated hugeshmget02.c and hugeshmget05.c to use SAFE_SHMGET() and configured the setup paths
so that shared memory allocation succeeds as expected.

In hugeshmget03.c, I also simplified the tst_brk() message by removing the unnecessary
__func__ usage and keeping a straightforward shmget() error message.

Patch v1: https://lore.kernel.org/ltp/20260407054943.125260-1-samir@linux.ibm.com/

Signed-off-by: Samir <samir@linux.ibm.com>
---
 testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c | 7 +++----
 testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c | 2 +-
 testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c | 7 +++----
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c
index bbd968c06..f808ac193 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c
@@ -12,6 +12,7 @@
  *	04/2004 - Updated by Robbie Williamson
  */
 #include <limits.h>
+#include "tst_safe_sysv_ipc.h"
 #include "hugetlb.h"
 
 static size_t shm_size;
@@ -77,10 +78,8 @@ void setup(void)
 
 	shmkey = getipckey();
 	shmkey2 = shmkey + 1;
-	shm_id_1 = shmget(shmkey, shm_size,
-			  SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
-	if (shm_id_1 == -1)
-		tst_brk(TBROK | TERRNO, "shmget #setup");
+	shm_id_1 = SAFE_SHMGET(shmkey, shm_size,
+			      SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
 }
 
 void cleanup(void)
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
index 625761f6e..0e8ad16fc 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
@@ -73,7 +73,7 @@ static void setup(void)
 				  SHM_HUGETLB | IPC_CREAT | IPC_EXCL | SHM_RW);
 	}
 	if (errno != ENOSPC)
-		tst_brk(TBROK | TERRNO, "shmget #setup");
+		tst_brk(TBROK | TERRNO, "shmget()");
 }
 
 static void cleanup(void)
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c
index 336319603..b34c93a08 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c
@@ -14,6 +14,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <limits.h>
+#include "tst_safe_sysv_ipc.h"
 #include "hugetlb.h"
 
 static size_t shm_size;
@@ -69,10 +70,8 @@ void setup(void)
 	shm_size = hpage_size * tst_hugepages / 2;
 	update_shm_size(&shm_size);
 	shmkey = getipckey();
-	shm_id_1 = shmget(shmkey, shm_size,
-			  SHM_HUGETLB | SHM_RW | IPC_CREAT | IPC_EXCL);
-	if (shm_id_1 == -1)
-		tst_brk(TBROK | TERRNO, "shmget #setup");
+	shm_id_1 = SAFE_SHMGET(shmkey, shm_size,
+			      SHM_HUGETLB | SHM_RW | IPC_CREAT | IPC_EXCL);
 
 	/* get the userid for a non-root user */
 	ltp_uid = getuserid(ltp_user);
-- 
2.53.0


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

                 reply	other threads:[~2026-04-12 14:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260412141039.1075095-1-samir@linux.ibm.com \
    --to=samir@linux.ibm.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox