syscalls/setns: Replace libc function with safe_macros
PATCH v2 1/1 syscalls/setns: Replace libc function with safe_macros
For those:
testcases/kernel/syscalls/setns/setns.h
testcases/kernel/syscalls/setns/setns02.c
Signed-off-by Zhao Gongyi <[email protected]>
---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(-)
testcases/kernel/syscalls/setns/setns.h +2 -4
@@ -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]); }
testcases/kernel/syscalls/setns/setns02.c +3 -3
@@ -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
PATCH v2 1/1 syscalls/setns: Replace libc function with safe_macros
Hi Zhao,
Quoted 1 line
v1->v2: add missed fd.
Thanks, merged!
Kind regards,
Petr