From: Zhao Gongyi <zhaogongyi@huawei.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/setns: Replace libc function with safe_macros
Date: Tue, 23 Mar 2021 21:57:30 +0800 [thread overview]
Message-ID: <20210323135730.24806-1-zhaogongyi@huawei.com> (raw)
For those:
testcases/kernel/syscalls/setns/setns.h
testcases/kernel/syscalls/setns/setns02.c
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
testcases/kernel/syscalls/setns/setns.h | 6 ++----
testcases/kernel/syscalls/setns/setns02.c | 6 +++---
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/testcases/kernel/syscalls/setns/setns.h b/testcases/kernel/syscalls/setns/setns.h
index c2097f2e5..f46a55a7b 100644
--- a/testcases/kernel/syscalls/setns/setns.h
+++ b/testcases/kernel/syscalls/setns/setns.h
@@ -19,9 +19,7 @@ static int get_ns_fd(int pid, const char *ns)
sprintf(tmp, "/proc/%d/ns/%s", pid, ns);
if (stat(tmp, &st) == 0) {
- fd = open(tmp, O_RDONLY);
- if (fd == -1)
- tst_brk(TBROK|TERRNO, "failed to open %s", tmp);
+ SAFE_OPEN(tmp, O_RDONLY);
} else {
if (errno != ENOENT)
tst_brk(TBROK|TERRNO, "failed to stat %s", tmp);
@@ -58,5 +56,5 @@ static void close_ns_fds(void)
for (i = 0; i < ns_total; i++)
if (ns_fds[i] != -1)
- close(ns_fds[i]);
+ SAFE_CLOSE(ns_fds[i]);
}
diff --git a/testcases/kernel/syscalls/setns/setns02.c b/testcases/kernel/syscalls/setns/setns02.c
index 0e20c52e4..db442541b 100644
--- a/testcases/kernel/syscalls/setns/setns02.c
+++ b/testcases/kernel/syscalls/setns/setns02.c
@@ -168,11 +168,11 @@ static void setup(void)
static void cleanup(void)
{
if (ns_ipc_fd != -1)
- close(ns_ipc_fd);
+ SAFE_CLOSE(ns_ipc_fd);
if (ns_uts_fd != -1)
- close(ns_uts_fd);
+ SAFE_CLOSE(ns_uts_fd);
- shmctl(shmid, IPC_RMID, NULL);
+ SAFE_SHMCTL(shmid, IPC_RMID, NULL);
}
static struct tst_test test = {
--
2.17.1
next reply other threads:[~2021-03-23 13:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-23 13:57 Zhao Gongyi [this message]
2021-03-24 20:31 ` [LTP] [PATCH] syscalls/setns: Replace libc function with safe_macros Petr Vorel
2021-03-25 2:41 zhaogongyi
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=20210323135730.24806-1-zhaogongyi@huawei.com \
--to=zhaogongyi@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.