[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 22/48] bsd-user: use qemu_strtoul in preference to strtol
From: |
imp |
Subject: |
[PATCH v2 22/48] bsd-user: use qemu_strtoul in preference to strtol |
Date: |
Sat, 24 Apr 2021 09:59:50 -0600 |
From: Warner Losh <imp@bsdimp.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/main.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 8f5cb7162d..a98a45df21 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -37,6 +37,7 @@
#include "tcg/tcg.h"
#include "qemu/timer.h"
#include "qemu/envlist.h"
+#include "qemu/cutils.h"
#include "exec/log.h"
#include "trace/control.h"
@@ -613,7 +614,7 @@ int main(int argc, char **argv)
TaskState ts1, *ts = &ts1;
CPUArchState *env;
CPUState *cpu;
- int optind;
+ int optind, rv;
const char *r;
const char *gdbstub = NULL;
char **target_environ, **wrk;
@@ -678,8 +679,8 @@ int main(int argc, char **argv)
}
} else if (!strcmp(r, "s")) {
r = argv[optind++];
- x86_stack_size = strtol(r, (char **)&r, 0);
- if (x86_stack_size <= 0) {
+ rv = qemu_strtoul(r, &r, 0, &x86_stack_size);
+ if (rv < 0 || x86_stack_size <= 0) {
usage();
}
if (*r == 'M') {
@@ -710,7 +711,10 @@ int main(int argc, char **argv)
exit(1);
}
} else if (!strcmp(r, "B")) {
- guest_base = strtol(argv[optind++], NULL, 0);
+ rv = qemu_strtoul(argv[optind++], NULL, 0, &guest_base);
+ if (rv < 0) {
+ usage();
+ }
have_guest_base = true;
} else if (!strcmp(r, "drop-ld-preload")) {
(void) envlist_unsetenv(envlist, "LD_PRELOAD");
--
2.22.1
- [PATCH v2 20/48] bsd-user: style tweak: use {} consistently in for / if / else statements, (continued)
- [PATCH v2 20/48] bsd-user: style tweak: use {} consistently in for / if / else statements, imp, 2021/04/24
- [PATCH v2 17/48] bsd-user: style tweak: Fix commentary issues, imp, 2021/04/24
- [PATCH v2 21/48] bsd-user: style nits: return is not a function, imp, 2021/04/24
- [PATCH v2 15/48] bsd-user: style tweak: return is not a function, eliminate (), imp, 2021/04/24
- [PATCH v2 12/48] bsd-user: style tweak: Remove #if 0'd code, imp, 2021/04/24
- [PATCH v2 14/48] bsd-user: style tweak: Remove #if 0'd code, imp, 2021/04/24
- [PATCH v2 22/48] bsd-user: use qemu_strtoul in preference to strtol,
imp <=
- [PATCH v2 10/48] bsd-user: Remove commented out code, imp, 2021/04/24
- [PATCH v2 24/48] bsd-user: create target_arch_cpu.h, imp, 2021/04/24
- [PATCH v2 32/48] bsd-user: style tweak: remove spacing after '*' and add after }, imp, 2021/04/24
- [PATCH v2 28/48] bsd-user: style tweak: comments, imp, 2021/04/24
- [PATCH v2 16/48] bsd-user: style tweak: Put {} around all if/else/for statements, imp, 2021/04/24