* [LTP] [PATCH] syscalls/setns: Replace libc function with safe_macros
@ 2021-03-23 13:57 Zhao Gongyi
2021-03-24 20:31 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Zhao Gongyi @ 2021-03-23 13:57 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>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [LTP] [PATCH] syscalls/setns: Replace libc function with safe_macros
2021-03-23 13:57 [LTP] [PATCH] syscalls/setns: Replace libc function with safe_macros Zhao Gongyi
@ 2021-03-24 20:31 ` Petr Vorel
0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2021-03-24 20:31 UTC (permalink / raw)
To: ltp
Hi Gongyi,
thanks for your patchset. While it looks correct, some of changes break both tests:
./setns01 -i 5
tst_test.c:1289: TINFO: Timeout per run is 0h 05m 00s
setns01.c:153: TCONF: no ns types/proc entries
./setns02 -i 5
tst_test.c:1289: TINFO: Timeout per run is 0h 05m 00s
setns02.c:160: TCONF: your kernel has CONFIG_IPC_NS, CONFIG_UTS_NS or CONFIG_PROC disabled
setns02.c:175: TWARN: shmctl(0, 0, (nil)) failed: EINVAL (22)
Kind regards,
Petr
^ permalink raw reply [flat|nested] 3+ messages in thread
* [LTP] [PATCH] syscalls/setns: Replace libc function with safe_macros
@ 2021-03-25 2:41 zhaogongyi
0 siblings, 0 replies; 3+ messages in thread
From: zhaogongyi @ 2021-03-25 2:41 UTC (permalink / raw)
To: ltp
Hi Petr,
I'm sorry! Its my fault, thanks for your review!
I have resubmit the patch.
Best Regards,
Gongyi
>
> Hi Gongyi,
>
> thanks for your patchset. While it looks correct, some of changes break
> both tests:
>
> ./setns01 -i 5
> tst_test.c:1289: TINFO: Timeout per run is 0h 05m 00s
> setns01.c:153: TCONF: no ns types/proc entries
>
> ./setns02 -i 5
> tst_test.c:1289: TINFO: Timeout per run is 0h 05m 00s
> setns02.c:160: TCONF: your kernel has CONFIG_IPC_NS, CONFIG_UTS_NS
> or CONFIG_PROC disabled
> setns02.c:175: TWARN: shmctl(0, 0, (nil)) failed: EINVAL (22)
>
> Kind regards,
> Petr
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-25 2:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 13:57 [LTP] [PATCH] syscalls/setns: Replace libc function with safe_macros Zhao Gongyi
2021-03-24 20:31 ` Petr Vorel
2021-03-25 2:41 zhaogongyi
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.