[LTP] [PATCH v2] syscalls/capget02: remove useless getpid()

Yang Xu xuyang2018.jy@cn.fujitsu.com
Thu Jan 9 08:26:05 CET 2020


Since pid=0 returns the capabilities for the calling thread,
we can remove getpid. Also we can cover this test point.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
-----------------
v1-v2:
remove pid = 0 assignment, because it has been initialized as 0.
add comment
-----------------
---
 testcases/kernel/syscalls/capget/capget02.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/syscalls/capget/capget02.c b/testcases/kernel/syscalls/capget/capget02.c
index 42c76a011..931632e47 100644
--- a/testcases/kernel/syscalls/capget/capget02.c
+++ b/testcases/kernel/syscalls/capget/capget02.c
@@ -69,15 +69,15 @@ static void verify_capget(unsigned int n)
 
 static void setup(void)
 {
-	unsigned int i, pid;
-
-	pid = getpid();
+	unsigned int i;
 
+	/*
+	 * Don't need to assign value to header.pid and bad_version_header.pid.
+	 * Because they have been initialized as 0 that it returns the capabilities
+	 * for the calling thread, equivalently to getpid().
+	 */
 	header.version = 0x19980330;
-	header.pid = pid;
-
 	bad_version_header.version = 0;
-	bad_version_header.pid = pid;
 
 	bad_pid_header.version = 0x19980330;
 	bad_pid_header.pid = -1;
-- 
2.18.0





More information about the ltp mailing list