mem/hugetlb: use SAFE_SHMGET() in hugeshmget setup function.
PATCH v2 1/1 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.
Patch v1: https://lore.kernel.org/ltp/[email protected]/
--- 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(-)
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c +3 -4
@@ -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 )
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c +1 -1
@@ -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 )
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget05.c +3 -4
@@ -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);
Signature · 5 lines
2.53.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 10 lines · Samir
I updated
hugeshmget02.candhugeshmget05.cto useSAFE_SHMGET()and configured the setup paths so that shared memory allocation succeeds as expected.In
hugeshmget03.c, I also simplified thetst_brk()message by removing the unnecessary__func__usage and keeping a straightforwardshmget()error message.Patch v1: https://lore.kernel.org/ltp/[email protected]/
Signed-off-by Samir <[email protected]>
It would be better to improve the patch description, but it's a minor issue that can be improved by people who apply it.
Signature · 6 lines
Regards, Li Wang Email: [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Samir,
Quoted 9 lines · Samir
mem/hugetlb: use
SAFE_SHMGET()in hugeshmget setup function.I updated
hugeshmget02.candhugeshmget05.cto useSAFE_SHMGET()and configured the setup paths so that shared memory allocation succeeds as expected.In
hugeshmget03.c, I also simplified thetst_brk()message by removing the unnecessary__func__usage and keeping a straightforwardshmget()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.
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c void setup(void) · line 82
Quoted 6 lines
testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget02.c +2
-4- 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
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Samir,
please send a new version with the requests, then I will merge.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp