* [LTP] [PATCH v2] mem/hugetlb: use SAFE_SHMGET() in hugeshmget setup function.
@ 2026-04-12 14:10 Samir
2026-04-13 3:37 ` Li Wang
2026-05-06 15:58 ` [LTP] " linuxtestproject.agent
0 siblings, 2 replies; 3+ messages in thread
From: Samir @ 2026-04-12 14:10 UTC (permalink / raw)
To: ltp; +Cc: Samir
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v2] mem/hugetlb: use SAFE_SHMGET() in hugeshmget setup function.
2026-04-12 14:10 [LTP] [PATCH v2] mem/hugetlb: use SAFE_SHMGET() in hugeshmget setup function Samir
@ 2026-04-13 3:37 ` Li Wang
2026-05-06 15:58 ` [LTP] " linuxtestproject.agent
1 sibling, 0 replies; 3+ messages in thread
From: Li Wang @ 2026-04-13 3:37 UTC (permalink / raw)
To: Samir; +Cc: ltp
Samir <samir@linux.ibm.com> wrote:
>
> 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>
It would be better to improve the patch description, but it's a minor issue
that can be improved by people who apply it.
Reviewed-by: Li Wang <wangli.ahau@gmail.com>
--
Regards,
Li Wang
Email: wangli.ahau@gmail.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] mem/hugetlb: use SAFE_SHMGET() in hugeshmget setup function.
2026-04-12 14:10 [LTP] [PATCH v2] mem/hugetlb: use SAFE_SHMGET() in hugeshmget setup function Samir
2026-04-13 3:37 ` Li Wang
@ 2026-05-06 15:58 ` linuxtestproject.agent
1 sibling, 0 replies; 3+ messages in thread
From: linuxtestproject.agent @ 2026-05-06 15:58 UTC (permalink / raw)
To: Samir; +Cc: ltp
Hi Samir,
On Sun, 12 Apr 2026, Samir wrote:
> mem/hugetlb: use SAFE_SHMGET() in hugeshmget setup function.
>
> 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.
The commit body describes what changed but not why. Add a sentence with
the motivation, e.g. "Replace the manual shmget()/tst_brk() pattern with
SAFE_SHMGET() to align with LTP conventions."
The SAFE_SHMGET() conversion (hugeshmget02, hugeshmget05) and the
tst_brk() message cleanup (hugeshmget03) are two independent logical
changes. Please split them into separate commits.
Remove the trailing period from the commit subject.
> - 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);
The continuation line is not aligned under the opening parenthesis of
SAFE_SHMGET(); fix the indentation (use tabs+spaces to land at column 33).
---
Note:
Our agent completed the review of the patch.
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-06 15:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-12 14:10 [LTP] [PATCH v2] mem/hugetlb: use SAFE_SHMGET() in hugeshmget setup function Samir
2026-04-13 3:37 ` Li Wang
2026-05-06 15:58 ` [LTP] " linuxtestproject.agent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox