public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] containers/userns05: use unsigned int for ns id
@ 2016-06-10 13:15 Jiri Jaburek
  2016-06-13 12:50 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Jiri Jaburek @ 2016-06-10 13:15 UTC (permalink / raw)
  To: ltp

The kernel defines it as 'unsigned int' in 'struct ns_common'
and formats it as

  snprintf(buf, size, "%s:[%u]", ns_ops->name, ns->inum);

This change makes the test work on 32bit systems where LONG_MAX
is smaller than UINT_MAX.

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
---
 testcases/kernel/containers/userns/userns05.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/containers/userns/userns05.c b/testcases/kernel/containers/userns/userns05.c
index 8d8c40a..8eac729 100644
--- a/testcases/kernel/containers/userns/userns05.c
+++ b/testcases/kernel/containers/userns/userns05.c
@@ -49,18 +49,18 @@ static int child_fn1(void)
 	return 0;
 }
 
-static long getusernsidbypid(int pid)
+static unsigned int getusernsidbypid(int pid)
 {
 	char path[BUFSIZ];
 	char userid[BUFSIZ];
-	long id = 0;
+	unsigned int id = 0;
 
 	sprintf(path, "/proc/%d/ns/user", pid);
 
 	if (readlink(path, userid, BUFSIZ) == -1)
 		tst_resm(TFAIL | TERRNO, "readlink failure.");
 
-	if (sscanf(userid, "user:[%ld]", &id) != 1)
+	if (sscanf(userid, "user:[%u]", &id) != 1)
 		tst_resm(TFAIL, "sscanf failure.");
 	return id;
 }
@@ -68,7 +68,7 @@ static long getusernsidbypid(int pid)
 static void test_userns_id(void)
 {
 	int cpid1, cpid2, cpid3;
-	long parentuserns, cpid1userns, cpid2userns, newparentuserns;
+	unsigned int parentuserns, cpid1userns, cpid2userns, newparentuserns;
 
 	parentuserns = getusernsidbypid(getpid());
 	cpid1 = ltp_clone_quick(SIGCHLD, (void *)child_fn1,
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [LTP] [PATCH] containers/userns05: use unsigned int for ns id
  2016-06-10 13:15 [LTP] [PATCH] containers/userns05: use unsigned int for ns id Jiri Jaburek
@ 2016-06-13 12:50 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2016-06-13 12:50 UTC (permalink / raw)
  To: ltp

Hi!
Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-13 12:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-10 13:15 [LTP] [PATCH] containers/userns05: use unsigned int for ns id Jiri Jaburek
2016-06-13 12:50 ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox