diff mbox series

[3/6] selftests/clone3: use uint64_t for flags parameter

Message ID 3f7bd9f0446360f90f12b9e9d3af1de2f5133a81.1568116761.git.esyr@redhat.com (mailing list archive)
State New
Headers show
Series Update clone3 self-tests | expand

Commit Message

Eugene Syromiatnikov Sept. 10, 2019, 12:03 p.m. UTC
Flags parameter in both userspace and kernel clone args is 64-bit wide,
there's little reason to have it signed and 32-bit in tests.

* tools/testing/selftests/clone3/clone3.c: Include <inttypes.h> and
<stdint.h>.
(call_clone3): Change flags parameter type from int to uint64_t.
(test_clone3): Change flags parameter type from int to uint64_t; change
the format string that prints it accordingly.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
---
 tools/testing/selftests/clone3/clone3.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

shuah Sept. 16, 2019, 4:40 p.m. UTC | #1
On 9/10/19 6:03 AM, Eugene Syromiatnikov wrote:
> Flags parameter in both userspace and kernel clone args is 64-bit wide,
> there's little reason to have it signed and 32-bit in tests.
> 

So what are doing? You are stating the problem here, how are you
fixing it?

> * tools/testing/selftests/clone3/clone3.c: Include <inttypes.h> and
> <stdint.h>.
> (call_clone3): Change flags parameter type from int to uint64_t.
> (test_clone3): Change flags parameter type from int to uint64_t; change
> the format string that prints it accordingly.
> 

I am not going to say this again. Please don't include pseudo code in
the commit log.

> Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
> ---
>   tools/testing/selftests/clone3/clone3.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c
> index 4f23a0c..1746a9b 100644
> --- a/tools/testing/selftests/clone3/clone3.c
> +++ b/tools/testing/selftests/clone3/clone3.c
> @@ -4,8 +4,10 @@
>   
>   #define _GNU_SOURCE
>   #include <errno.h>
> +#include <inttypes.h>
>   #include <linux/types.h>
>   #include <linux/sched.h>
> +#include <stdint.h>
>   #include <stdio.h>
>   #include <stdlib.h>
>   #include <sys/syscall.h>
> @@ -36,7 +38,7 @@ static pid_t raw_clone(struct clone_args *args, size_t size)
>   	return syscall(__NR_clone3, args, size);
>   }
>   
> -static int call_clone3(int flags, size_t size, enum test_mode test_mode)
> +static int call_clone3(uint64_t flags, size_t size, enum test_mode test_mode)
>   {
>   	struct clone_args args = {0};
>   	pid_t ppid = -1;
> @@ -102,12 +104,13 @@ static int call_clone3(int flags, size_t size, enum test_mode test_mode)
>   	return 0;
>   }
>   
> -static int test_clone3(int flags, size_t size, int expected,
> +static int test_clone3(uint64_t flags, size_t size, int expected,
>   		       enum test_mode test_mode)
>   {
>   	int ret;
>   
> -	ksft_print_msg("[%d] Trying clone3() with flags 0x%x (size %d)\n",
> +	ksft_print_msg("[%d] Trying clone3() with flags %#" PRIx64 " (size %d)"
> +			"\n",
>   			getpid(), flags, size);
>   	ret = call_clone3(flags, size, test_mode);
>   	ksft_print_msg("[%d] clone3() with flags says :%d expected %d\n",
> 

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c
index 4f23a0c..1746a9b 100644
--- a/tools/testing/selftests/clone3/clone3.c
+++ b/tools/testing/selftests/clone3/clone3.c
@@ -4,8 +4,10 @@ 
 
 #define _GNU_SOURCE
 #include <errno.h>
+#include <inttypes.h>
 #include <linux/types.h>
 #include <linux/sched.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/syscall.h>
@@ -36,7 +38,7 @@  static pid_t raw_clone(struct clone_args *args, size_t size)
 	return syscall(__NR_clone3, args, size);
 }
 
-static int call_clone3(int flags, size_t size, enum test_mode test_mode)
+static int call_clone3(uint64_t flags, size_t size, enum test_mode test_mode)
 {
 	struct clone_args args = {0};
 	pid_t ppid = -1;
@@ -102,12 +104,13 @@  static int call_clone3(int flags, size_t size, enum test_mode test_mode)
 	return 0;
 }
 
-static int test_clone3(int flags, size_t size, int expected,
+static int test_clone3(uint64_t flags, size_t size, int expected,
 		       enum test_mode test_mode)
 {
 	int ret;
 
-	ksft_print_msg("[%d] Trying clone3() with flags 0x%x (size %d)\n",
+	ksft_print_msg("[%d] Trying clone3() with flags %#" PRIx64 " (size %d)"
+			"\n",
 			getpid(), flags, size);
 	ret = call_clone3(flags, size, test_mode);
 	ksft_print_msg("[%d] clone3() with flags says :%d expected %d\n",