public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] selftests: KVM: Replace optarg with arg in guest_modes_cmdline
@ 2023-02-02  2:57 shahuang
  2023-02-02  8:10 ` Andrew Jones
  2023-02-08  2:07 ` Sean Christopherson
  0 siblings, 2 replies; 5+ messages in thread
From: shahuang @ 2023-02-02  2:57 UTC (permalink / raw)
  To: kvm
  Cc: Shaoqin Huang, Paolo Bonzini, Shuah Khan, Sean Christopherson,
	open list:KERNEL SELFTEST FRAMEWORK, open list

From: Shaoqin Huang <shahuang@redhat.com>

The parameter arg in guest_modes_cmdline not being used now, and the
optarg should be replaced with arg in guest_modes_cmdline.

And this is the chance to change strtoul() to atoi_non_negative(), since
guest mode ID will never be negative.

Signed-off-by: Shaoqin Huang <shahuang@redhat.com>

---
Changes from v1:
  - Change strtoul() to atoi_non_negative(). [Vipin]

---
 tools/testing/selftests/kvm/lib/guest_modes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/lib/guest_modes.c b/tools/testing/selftests/kvm/lib/guest_modes.c
index 99a575bbbc52..1df3ce4b16fd 100644
--- a/tools/testing/selftests/kvm/lib/guest_modes.c
+++ b/tools/testing/selftests/kvm/lib/guest_modes.c
@@ -127,7 +127,7 @@ void guest_modes_cmdline(const char *arg)
 		mode_selected = true;
 	}
 
-	mode = strtoul(optarg, NULL, 10);
+	mode = atoi_non_negative("Guest mode ID", arg);
 	TEST_ASSERT(mode < NUM_VM_MODES, "Guest mode ID %d too big", mode);
 	guest_modes[mode].enabled = true;
 }
-- 
2.39.0


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

* Re: [PATCH v2] selftests: KVM: Replace optarg with arg in guest_modes_cmdline
  2023-02-02  2:57 [PATCH v2] selftests: KVM: Replace optarg with arg in guest_modes_cmdline shahuang
@ 2023-02-02  8:10 ` Andrew Jones
  2023-02-02 18:05   ` Vipin Sharma
  2023-02-08  2:07 ` Sean Christopherson
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Jones @ 2023-02-02  8:10 UTC (permalink / raw)
  To: shahuang
  Cc: kvm, Paolo Bonzini, Shuah Khan, Sean Christopherson,
	open list:KERNEL SELFTEST FRAMEWORK, open list

On Thu, Feb 02, 2023 at 10:57:15AM +0800, shahuang@redhat.com wrote:
> From: Shaoqin Huang <shahuang@redhat.com>
> 
> The parameter arg in guest_modes_cmdline not being used now, and the
> optarg should be replaced with arg in guest_modes_cmdline.
> 
> And this is the chance to change strtoul() to atoi_non_negative(), since
> guest mode ID will never be negative.

Fixes: e42ac777d661 ("KVM: selftests: Factor out guest mode code")

> 
> Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
> 
> ---
> Changes from v1:
>   - Change strtoul() to atoi_non_negative(). [Vipin]
> 
> ---
>  tools/testing/selftests/kvm/lib/guest_modes.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/kvm/lib/guest_modes.c b/tools/testing/selftests/kvm/lib/guest_modes.c
> index 99a575bbbc52..1df3ce4b16fd 100644
> --- a/tools/testing/selftests/kvm/lib/guest_modes.c
> +++ b/tools/testing/selftests/kvm/lib/guest_modes.c
> @@ -127,7 +127,7 @@ void guest_modes_cmdline(const char *arg)
>  		mode_selected = true;
>  	}
>  
> -	mode = strtoul(optarg, NULL, 10);
> +	mode = atoi_non_negative("Guest mode ID", arg);
>  	TEST_ASSERT(mode < NUM_VM_MODES, "Guest mode ID %d too big", mode);
>  	guest_modes[mode].enabled = true;
>  }
> -- 
> 2.39.0
> 

Reviewed-by: Andrew Jones <andrew.jones@linux.dev>

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

* Re: [PATCH v2] selftests: KVM: Replace optarg with arg in guest_modes_cmdline
  2023-02-02  8:10 ` Andrew Jones
@ 2023-02-02 18:05   ` Vipin Sharma
  0 siblings, 0 replies; 5+ messages in thread
From: Vipin Sharma @ 2023-02-02 18:05 UTC (permalink / raw)
  To: Andrew Jones
  Cc: shahuang, kvm, Paolo Bonzini, Shuah Khan, Sean Christopherson,
	open list:KERNEL SELFTEST FRAMEWORK, open list

On Thu, Feb 2, 2023 at 12:11 AM Andrew Jones <andrew.jones@linux.dev> wrote:
>
> On Thu, Feb 02, 2023 at 10:57:15AM +0800, shahuang@redhat.com wrote:
> > From: Shaoqin Huang <shahuang@redhat.com>
> >
> > The parameter arg in guest_modes_cmdline not being used now, and the
> > optarg should be replaced with arg in guest_modes_cmdline.
> >
> > And this is the chance to change strtoul() to atoi_non_negative(), since
> > guest mode ID will never be negative.
>
> Fixes: e42ac777d661 ("KVM: selftests: Factor out guest mode code")
>
> >
> > Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
> >
> > ---
> > Changes from v1:
> >   - Change strtoul() to atoi_non_negative(). [Vipin]
> >
> > ---
> >  tools/testing/selftests/kvm/lib/guest_modes.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/kvm/lib/guest_modes.c b/tools/testing/selftests/kvm/lib/guest_modes.c
> > index 99a575bbbc52..1df3ce4b16fd 100644
> > --- a/tools/testing/selftests/kvm/lib/guest_modes.c
> > +++ b/tools/testing/selftests/kvm/lib/guest_modes.c
> > @@ -127,7 +127,7 @@ void guest_modes_cmdline(const char *arg)
> >               mode_selected = true;
> >       }
> >
> > -     mode = strtoul(optarg, NULL, 10);
> > +     mode = atoi_non_negative("Guest mode ID", arg);
> >       TEST_ASSERT(mode < NUM_VM_MODES, "Guest mode ID %d too big", mode);
> >       guest_modes[mode].enabled = true;
> >  }
> > --
> > 2.39.0
> >
>
> Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Reviewed-by: Vipin Sharma <vipinsh@google.com>

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

* Re: [PATCH v2] selftests: KVM: Replace optarg with arg in guest_modes_cmdline
  2023-02-02  2:57 [PATCH v2] selftests: KVM: Replace optarg with arg in guest_modes_cmdline shahuang
  2023-02-02  8:10 ` Andrew Jones
@ 2023-02-08  2:07 ` Sean Christopherson
  2023-02-08 14:45   ` Sean Christopherson
  1 sibling, 1 reply; 5+ messages in thread
From: Sean Christopherson @ 2023-02-08  2:07 UTC (permalink / raw)
  To: Sean Christopherson, kvm, shahuang
  Cc: Paolo Bonzini, Shuah Khan, linux-kselftest, linux-kernel

On Thu, 02 Feb 2023 10:57:15 +0800, shahuang@redhat.com wrote:
> The parameter arg in guest_modes_cmdline not being used now, and the
> optarg should be replaced with arg in guest_modes_cmdline.
> 
> And this is the chance to change strtoul() to atoi_non_negative(), since
> guest mode ID will never be negative.
> 
> 
> [...]

Applied to kvm-x86 selftests, thanks!

[1/1] selftests: KVM: Replace optarg with arg in guest_modes_cmdline
      https://github.com/kvm-x86/linux/commit/62f86202d76d

--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes

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

* Re: [PATCH v2] selftests: KVM: Replace optarg with arg in guest_modes_cmdline
  2023-02-08  2:07 ` Sean Christopherson
@ 2023-02-08 14:45   ` Sean Christopherson
  0 siblings, 0 replies; 5+ messages in thread
From: Sean Christopherson @ 2023-02-08 14:45 UTC (permalink / raw)
  To: kvm, shahuang; +Cc: Paolo Bonzini, Shuah Khan, linux-kselftest, linux-kernel

On Wed, Feb 08, 2023, Sean Christopherson wrote:
> On Thu, 02 Feb 2023 10:57:15 +0800, shahuang@redhat.com wrote:
> > The parameter arg in guest_modes_cmdline not being used now, and the
> > optarg should be replaced with arg in guest_modes_cmdline.
> > 
> > And this is the chance to change strtoul() to atoi_non_negative(), since
> > guest mode ID will never be negative.
> > 
> > 
> > [...]
> 
> Applied to kvm-x86 selftests, thanks!
> 
> [1/1] selftests: KVM: Replace optarg with arg in guest_modes_cmdline
>       https://github.com/kvm-x86/linux/commit/62f86202d76d

I force pushed to selftests because of a goof on my end, new SHA-1 is:

  https://github.com/kvm-x86/linux/commit/7ae69d7087a9

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

end of thread, other threads:[~2023-02-08 14:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-02  2:57 [PATCH v2] selftests: KVM: Replace optarg with arg in guest_modes_cmdline shahuang
2023-02-02  8:10 ` Andrew Jones
2023-02-02 18:05   ` Vipin Sharma
2023-02-08  2:07 ` Sean Christopherson
2023-02-08 14:45   ` Sean Christopherson

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