summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/aarch64/vgic_irq.c
diff options
context:
space:
mode:
authorVipin Sharma <vipinsh@google.com>2022-11-03 22:17:15 +0300
committerSean Christopherson <seanjc@google.com>2022-11-16 21:03:24 +0300
commit018ea2d71a43372cb984021f03514dc6dd3d46df (patch)
tree0c8b29c542aa023906296179eb252c9eedbbb69c /tools/testing/selftests/kvm/aarch64/vgic_irq.c
parent0eb88a4121861ce3d5f925a183abb13ad954dbe6 (diff)
downloadlinux-018ea2d71a43372cb984021f03514dc6dd3d46df.tar.xz
KVM: selftests: Add atoi_paranoid() to catch errors missed by atoi()
atoi() doesn't detect errors. There is no way to know that a 0 return is correct conversion or due to an error. Introduce atoi_paranoid() to detect errors and provide correct conversion. Replace all atoi() calls with atoi_paranoid(). Signed-off-by: Vipin Sharma <vipinsh@google.com> Suggested-by: David Matlack <dmatlack@google.com> Suggested-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20221103191719.1559407-4-vipinsh@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/aarch64/vgic_irq.c')
-rw-r--r--tools/testing/selftests/kvm/aarch64/vgic_irq.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/testing/selftests/kvm/aarch64/vgic_irq.c b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
index 17417220a083..ae90b718070a 100644
--- a/tools/testing/selftests/kvm/aarch64/vgic_irq.c
+++ b/tools/testing/selftests/kvm/aarch64/vgic_irq.c
@@ -824,16 +824,16 @@ int main(int argc, char **argv)
while ((opt = getopt(argc, argv, "hn:e:l:")) != -1) {
switch (opt) {
case 'n':
- nr_irqs = atoi(optarg);
+ nr_irqs = atoi_paranoid(optarg);
if (nr_irqs > 1024 || nr_irqs % 32)
help(argv[0]);
break;
case 'e':
- eoi_split = (bool)atoi(optarg);
+ eoi_split = (bool)atoi_paranoid(optarg);
default_args = false;
break;
case 'l':
- level_sensitive = (bool)atoi(optarg);
+ level_sensitive = (bool)atoi_paranoid(optarg);
default_args = false;
break;
case 'h':