public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] syscalls/setns: Replace libc function with safe_macros
@ 2021-03-25  2:38 Zhao Gongyi
  2021-03-30  9:23 ` Petr Vorel
  0 siblings, 1 reply; 2+ messages in thread
From: Zhao Gongyi @ 2021-03-25  2:38 UTC (permalink / raw)
  To: ltp

For those:
	testcases/kernel/syscalls/setns/setns.h
	testcases/kernel/syscalls/setns/setns02.c

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
v1->v2: add missed fd.

 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..46beef17f 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);
+		fd = 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [LTP] [PATCH v2] syscalls/setns: Replace libc function with safe_macros
  2021-03-25  2:38 [LTP] [PATCH v2] syscalls/setns: Replace libc function with safe_macros Zhao Gongyi
@ 2021-03-30  9:23 ` Petr Vorel
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2021-03-30  9:23 UTC (permalink / raw)
  To: ltp

Hi Zhao,

> v1->v2: add missed fd.
Thanks, merged!

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-30  9:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-25  2:38 [LTP] [PATCH v2] syscalls/setns: Replace libc function with safe_macros Zhao Gongyi
2021-03-30  9:23 ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox