linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: shuah <shuah@kernel.org>
To: Eugene Syromiatnikov <esyr@redhat.com>,
	linux-kernel@vger.kernel.org,
	Christian Brauner <christian@brauner.io>,
	linux-kselftest@vger.kernel.org
Cc: Adrian Reber <areber@redhat.com>, shuah <shuah@kernel.org>
Subject: Re: [PATCH 1/6] selftests/clone3: convert test modes into an enum
Date: Mon, 16 Sep 2019 10:28:55 -0600	[thread overview]
Message-ID: <65383c0a-90d5-ed79-284d-1c084933d860@kernel.org> (raw)
In-Reply-To: <96cf2b235f525321a562e9727b3fa0b05675efe8.1568116761.git.esyr@redhat.com>

On 9/10/19 6:03 AM, Eugene Syromiatnikov wrote:
> * tools/testing/selftests/clone3/clone3.c (CLONE3_ARGS_NO_TEST,
> CLONE3_ARGS_ALL_0, CLONE3_ARGS_ALL_1): Change into an enum.
> (call_clone3): Change test_mode parameter type to enum test_mode;
> use switch statement for actions that dependent on test_mode selection.
> (test_clone3): Change test_mode parameter type to enum test_mode.
> 

You don't need the file name in the commit log. Please describe what
you are fixing/doing in the commit. Describing the actual code changes
doesn't help.

Including why these changes are needed as opposed the actual changes
will be helpful. I think I know why, I would like you to tell me why.

> Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
> ---
>   tools/testing/selftests/clone3/clone3.c | 21 ++++++++++++++-------
>   1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c
> index a0f1989..7b65ee5 100644
> --- a/tools/testing/selftests/clone3/clone3.c
> +++ b/tools/testing/selftests/clone3/clone3.c
> @@ -24,16 +24,18 @@
>   /* V1 includes set_tid */
>   #define CLONE3_ARGS_SIZE_V1 72
>   
> -#define CLONE3_ARGS_NO_TEST 0
> -#define CLONE3_ARGS_ALL_0 1
> -#define CLONE3_ARGS_ALL_1 2
> +enum test_mode {
> +	CLONE3_ARGS_NO_TEST,
> +	CLONE3_ARGS_ALL_0,
> +	CLONE3_ARGS_ALL_1,
> +};
>   
>   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, int test_mode)
> +static int call_clone3(int flags, size_t size, enum test_mode test_mode)
>   {
>   	struct clone_args args = {0};
>   	pid_t ppid = -1;
> @@ -46,7 +48,8 @@ static int call_clone3(int flags, size_t size, int test_mode)
>   	if (size == 0)
>   		size = sizeof(struct clone_args);
>   
> -	if (test_mode == CLONE3_ARGS_ALL_0) {
> +	switch (test_mode) {
> +	case CLONE3_ARGS_ALL_0:
>   		args.flags = 0;
>   		args.pidfd = 0;
>   		args.child_tid = 0;
> @@ -56,7 +59,9 @@ static int call_clone3(int flags, size_t size, int test_mode)
>   		args. stack_size = 0;
>   		args.tls = 0;
>   		args.set_tid = 0;
> -	} else if (test_mode == CLONE3_ARGS_ALL_1) {
> +		break;
> +
> +	case CLONE3_ARGS_ALL_1:
>   		args.flags = 1;
>   		args.pidfd = 1;
>   		args.child_tid = 1;
> @@ -66,6 +71,7 @@ static int call_clone3(int flags, size_t size, int test_mode)
>   		args. stack_size = 1;
>   		args.tls = 1;
>   		args.set_tid = 1;
> +		break;
>   	}
>   
>   	pid = raw_clone(&args, size);
> @@ -91,7 +97,8 @@ static int call_clone3(int flags, size_t size, int test_mode)
>   	return 0;
>   }
>   
> -static int test_clone3(int flags, size_t size, int expected, int test_mode)
> +static int test_clone3(int flags, size_t size, int expected,
> +		       enum test_mode test_mode)
>   {
>   	int ret;
>   
> 

thanks,
-- Shuah

  reply	other threads:[~2019-09-16 16:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10 12:02 [PATCH 0/6] Update clone3 self-tests Eugene Syromiatnikov
2019-09-10 12:03 ` [PATCH 1/6] selftests/clone3: convert test modes into an enum Eugene Syromiatnikov
2019-09-16 16:28   ` shuah [this message]
2019-09-10 12:03 ` [PATCH 2/6] selftests/clone3: add a check for invalid exit_signal Eugene Syromiatnikov
2019-09-16 16:37   ` shuah
2019-09-10 12:03 ` [PATCH 3/6] selftests/clone3: use uint64_t for flags parameter Eugene Syromiatnikov
2019-09-16 16:40   ` shuah
2019-09-10 12:03 ` [PATCH 4/6] selftests/clone3: fix up format strings Eugene Syromiatnikov
2019-09-16 16:41   ` shuah
2019-09-10 12:03 ` [PATCH 5/6] selftests/clone3: enable clone3 self-tests on all architectures Eugene Syromiatnikov
2019-09-16 16:44   ` shuah
2019-09-10 12:03 ` [PATCH 6/6] selftests: add clone3 to TARGETS Eugene Syromiatnikov
2019-09-16 16:48   ` shuah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=65383c0a-90d5-ed79-284d-1c084933d860@kernel.org \
    --to=shuah@kernel.org \
    --cc=areber@redhat.com \
    --cc=christian@brauner.io \
    --cc=esyr@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).