containers/userns05: use unsigned int for ns id
PATCH 1/1 containers/userns05: use unsigned int for ns id
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 <[email protected]>
--- testcases/kernel/containers/userns/userns05.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
testcases/kernel/containers/userns/userns05.c +4 -4
@@ -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,
Signature · 1 line
2.4.3
PATCH 1/1 containers/userns05: use unsigned int for ns id
Hi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]