[v2] syscalls/capget02: remove useless getpid()
diff mbox series

Message ID 1578554765-30025-1-git-send-email-xuyang2018.jy@cn.fujitsu.com
State Accepted
Headers show
Series
  • [v2] syscalls/capget02: remove useless getpid()
Related show

Commit Message

Yang Xu Jan. 9, 2020, 7:26 a.m. UTC
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(-)

Comments

Petr Vorel Jan. 10, 2020, 1 p.m. UTC | #1
Hi Xu,

> 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
Reviewed-by: Petr Vorel <pvorel@suse.cz>

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


Kind regards,
Petr
Petr Vorel Jan. 10, 2020, 4:42 p.m. UTC | #2
Hi Xu,

> > 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
> Reviewed-by: Petr Vorel <pvorel@suse.cz>

> 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

Patch
diff mbox series

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;