[LTP] hugetlb/hugeshmget: Add hugeshmget07 to test SHM_HUGETLB with /dev/zero read
linuxtestproject.agent@gmail.com
linuxtestproject.agent@gmail.com
Wed Sep 23 11:59:09 CEST 2026
Hi Pavithra,
On Wed, 23 Sep 2026 14:03:00 +0530, Pavithra <pavrampu@linux.ibm.com> wrote:
> hugetlb/hugeshmget: Add hugeshmget07 to test SHM_HUGETLB with /dev/zero read
>+ zero_fd = SAFE_OPEN("/dev/zero", O_RDONLY);
>+
>+ shmid = SAFE_SHMGET(IPC_PRIVATE, size, SHM_HUGETLB | SHM_R | SHM_W);
>+
>+ shmaddr = SAFE_SHMAT(shmid, 0, SHM_RND);
>+ tst_res(TINFO, "shmaddr: %p", shmaddr);
>+
>+ for (i = 0; i < size; i += hpage_size) {
>+ TST_EXP_VAL(read(zero_fd, shmaddr + i, hpage_size),
>+ (ssize_t)hpage_size);
>+ }
>+
>+ SAFE_CLOSE(zero_fd);
File descriptors must be initialized to -1 and closed in cleanup() with an
fd != -1 guard. If SAFE_SHMGET() or SAFE_SHMAT() aborts, zero_fd is not
closed. Define static int zero_fd = -1 at file scope, open it in setup(),
and close it in cleanup().
>+ SAFE_SHMCTL(shmid, IPC_RMID, NULL);
>+ shmid = -1;
SAFE_SHMCTL() sets shmid to -1 when called with IPC_RMID. The subsequent
shmid = -1 assignment is redundant.
Verdict - Needs revision
---
Note:
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
More information about the ltp
mailing list