[LTP] [PATCH 2/2] Make use of SAFE_GETGRNAM()

Petr Vorel pvorel@suse.cz
Fri Jun 15 16:47:17 CEST 2018


Hi Jinhui,

> Signed-off-by: Jinhui Huang <huangjh.jy@cn.fujitsu.com>
> ---
>  testcases/kernel/syscalls/chmod/chmod05.c       |  4 +---
>  testcases/kernel/syscalls/chmod/chmod07.c       |  3 +--
>  testcases/kernel/syscalls/creat/creat08.c       | 16 +++++-----------
>  testcases/kernel/syscalls/fchmod/fchmod02.c     |  4 +---
>  testcases/kernel/syscalls/fchmod/fchmod05.c     |  5 +----
>  testcases/kernel/syscalls/open/open10.c         | 14 ++++----------
>  testcases/kernel/syscalls/setregid/setregid02.c |  5 +----
>  testcases/kernel/syscalls/setregid/setregid03.c |  5 +----
>  testcases/kernel/syscalls/setregid/setregid04.c |  6 ++----
>  9 files changed, 17 insertions(+), 45 deletions(-)

I took only change in fchmod02 and adjusted it into new API.

Thanks for both patches!

Kind regards,
Petr

diff --git testcases/kernel/syscalls/fchmod/fchmod02.c testcases/kernel/syscalls/fchmod/fchmod02.c
index c41fd39e3..a855f9567 100644
--- testcases/kernel/syscalls/fchmod/fchmod02.c
+++ testcases/kernel/syscalls/fchmod/fchmod02.c
@@ -54,9 +54,7 @@ static void setup(void)
 	struct group *ltpgroup;
 
 	ltpuser = SAFE_GETPWNAM(LTPUSER);
-	ltpgroup = getgrnam(LTPGRP);
-	if (ltpgroup == NULL)
-		tst_brk(TBROK, "%s not in /etc/group", LTPGRP);
+	ltpgroup = SAFE_GETGRNAM(LTPGRP);
 
 	fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, FILE_MODE);
 	SAFE_CHOWN(TESTFILE, ltpuser->pw_uid, ltpgroup->gr_gid);


More information about the ltp mailing list