From: Cyril Hrubis <chrubis@suse.cz>
To: linuxtestproject.agent@gmail.com
Cc: Pavithra <pavrampu@linux.ibm.com>, ltp@lists.linux.it
Subject: Re: [LTP] hugetlb/hugeshmget: Add hugeshmget07 to test SHM_HUGETLB with /dev/zero read
Date: Mon, 2 Nov 2026 17:15:31 +0100 [thread overview]
Message-ID: <aui3I3FvsAE86Zsi@yuki.lan> (raw)
In-Reply-To: <20260923095909.9312-1-linuxtestproject.agent@gmail.com>
Hi!
> >+ 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.
These two are valid, the rest of the code looks good.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-11-02 16:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 8:33 [LTP] [PATCH v8] hugetlb/hugeshmget: Add hugeshmget07 to test SHM_HUGETLB with /dev/zero read Pavithra
2026-09-23 9:59 ` [LTP] " linuxtestproject.agent
2026-11-02 16:15 ` Cyril Hrubis [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-11-07 4:44 [LTP] [PATCH v9] " Pavithra
2026-11-07 10:46 ` [LTP] " linuxtestproject.agent
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=aui3I3FvsAE86Zsi@yuki.lan \
--to=chrubis@suse.cz \
--cc=linuxtestproject.agent@gmail.com \
--cc=ltp@lists.linux.it \
--cc=pavrampu@linux.ibm.com \
/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