Skip to contentSkip to conversation

syscalls/capget02: remove useless getpid()

PATCH New Yang Xu 2 participants 3 messages Jan 9, 2020 – Jan 10, 2020

lore
Share & tools
lore

Yang Xu

author
#0 lore raw

PATCH v2 1/1 syscalls/capget02: remove useless getpid()

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

-----------------
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(-)
testcases/kernel/syscalls/capget/capget02.c +6 -6
index 42c76a011..931632e47 100644
@@ -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;
Signature · 1 line
2.18.0
#1 lore raw

PATCH v2 1/1 syscalls/capget02: remove useless getpid()

Hi Xu,

Quoted 8 lines

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

-----------------
v1-v2:
remove pid = 0 assignment, because it has been initialized as 0. add comment

Note, waiting for merge before current git get's fixed. (v2 of https://patchwork.ozlabs.org/patch/1220180/).

Kind regards,
Petr

#2 lore raw

PATCH v2 1/1 syscalls/capget02: remove useless getpid()

Hi Xu,

Quoted 8 lines
Quoted 8 lines

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

-----------------
v1-v2:
remove pid = 0 assignment, because it has been initialized as 0. add comment

Quoted 4 lines

Note, waiting for merge before current git get's fixed. (v2 of https://patchwork.ozlabs.org/patch/1220180/).

Thanks for your patch, merged.

Kind regards,
Petr