Skip to content

Commit 62f8620

Browse files
shaoqinhsean-jc
authored andcommitted
selftests: KVM: Replace optarg with arg in guest_modes_cmdline
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> Fixes: e42ac77 ("KVM: selftests: Factor out guest mode code") Reviewed-by: Andrew Jones <andrew.jones@linux.dev> Reviewed-by: Vipin Sharma <vipinsh@google.com> Link: https://lore.kernel.org/r/20230202025716.216323-1-shahuang@redhat.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 4dfd8e3 commit 62f8620

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/kvm/lib/guest_modes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void guest_modes_cmdline(const char *arg)
127127
mode_selected = true;
128128
}
129129

130-
mode = strtoul(optarg, NULL, 10);
130+
mode = atoi_non_negative("Guest mode ID", arg);
131131
TEST_ASSERT(mode < NUM_VM_MODES, "Guest mode ID %d too big", mode);
132132
guest_modes[mode].enabled = true;
133133
}

0 commit comments

Comments
 (0)