selftests: KVM: Replace optarg with arg in guest_modes_cmdline
PATCH v2 1/1 selftests: KVM: Replace optarg with arg in guest_modes_cmdline
From: Shaoqin Huang <[email protected]>
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.
---
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(-)
tools/testing/selftests/kvm/lib/guest_modes.c +1 -1
@@ -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; }
Signature · 1 line
2.39.0
Quoted 7 lines · On Thu, Feb 02, 2023 at 10:57:15AM +0800, [email protected] wrote:
From: Shaoqin Huang <[email protected]>
The parameter arg in
guest_modes_cmdlinenot being used now, and the optarg should be replaced with arg inguest_modes_cmdline.And this is the chance to change
strtoul()toatoi_non_negative(), since guest mode ID will never be negative.
Quoted 27 lines
Signed-off-by Shaoqin Huang <[email protected]>---
Changes from v1:
- Changestrtoul()toatoi_non_negative(). [Vipin]--- tools/testing/selftests/kvm/lib/guest_modes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/kvm/lib/guest_modes.c +1
-1@@ -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; }Signature · 1 line
2.39.0
Vipin Sharma
Reviewed-byQuoted 31 lines · Andrew Jones
Quoted 7 lines · On Thu, Feb 02, 2023 at 10:57:15AM +0800, [email protected] wrote:
From: Shaoqin Huang <[email protected]>
The parameter arg in
guest_modes_cmdlinenot being used now, and the optarg should be replaced with arg inguest_modes_cmdline.And this is the chance to change
strtoul()toatoi_non_negative(), since guest mode ID will never be negative.Fixes e42ac777d661 ("KVM: selftests: Factor out guest mode code")Quoted 19 lines
Signed-off-by Shaoqin Huang <[email protected]>---
Changes from v1:
- Changestrtoul()toatoi_non_negative(). [Vipin]--- tools/testing/selftests/kvm/lib/guest_modes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/kvm/lib/guest_modes.c +0
-0@@ -127,7 +127,7 @@ void guest_modes_cmdline(const char *arg) mode_selected = true; }
Quoted 10 lines
Quoted 8 lines
tools/testing/selftests/kvm/lib/guest_modes.c +1
-2- 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 <[email protected]>
Sean Christopherson
reviewerQuoted 8 lines · On Thu, 02 Feb 2023 10:57:15 +0800, [email protected] wrote:
The parameter arg in
guest_modes_cmdlinenot being used now, and the optarg should be replaced with arg inguest_modes_cmdline.And this is the chance to change
strtoul()toatoi_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
Sean Christopherson
reviewerQuoted 8 lines · Sean Christopherson
Quoted 7 lines · On Thu, 02 Feb 2023 10:57:15 +0800, [email protected] wrote:
The parameter arg in
guest_modes_cmdlinenot being used now, and the optarg should be replaced with arg inguest_modes_cmdline.And this is the chance to change
strtoul()toatoi_non_negative(), since guest mode ID will never be negative.
Quoted 6 lines
Quoted 1 line
[...]
Applied to kvm-x86 selftests, thanks!
[1/1] selftests: KVM: Replace optarg with arg in
guest_modes_cmdlinehttps://github.com/kvm-x86/linux/commit/62f86202d76d
I force pushed to selftests because of a goof on my end, new SHA-1 is: