[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/20] bsd-user: use qemu_strtoul in preference to strtol
From: |
Warner Losh |
Subject: |
[PULL 12/20] bsd-user: use qemu_strtoul in preference to strtol |
Date: |
Wed, 12 May 2021 11:17:12 -0600 |
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
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 0f9e6bfbc0..18f806b032 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -36,6 +36,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"
@@ -612,7 +613,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;
@@ -677,8 +678,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') {
@@ -709,7 +710,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
- [PULL 04/20] bsd-user: style tweak: Use preferred block comments, (continued)
- [PULL 04/20] bsd-user: style tweak: Use preferred block comments, Warner Losh, 2021/05/12
- [PULL 05/20] bsd-user: Remove commented out code, Warner Losh, 2021/05/12
- [PULL 08/20] bsd-user: style tweak: Use preferred block comments, Warner Losh, 2021/05/12
- [PULL 15/20] bsd-user: style tweak: keyword space (, Warner Losh, 2021/05/12
- [PULL 11/20] bsd-user: style tweak: use {} consistently in for / if / else statements, Warner Losh, 2021/05/12
- [PULL 18/20] bsd-user: remove target_signal.h, it's unused, Warner Losh, 2021/05/12
- [PULL 14/20] bsd-user: style tweak: keyword space (, Warner Losh, 2021/05/12
- [PULL 17/20] bsd-user: style tweak: keyword space (, Warner Losh, 2021/05/12
- [PULL 19/20] bsd-user: Stop building the sparc targets, Warner Losh, 2021/05/12
- [PULL 16/20] bsd-user: style tweak: Remove #if 0'd code, Warner Losh, 2021/05/12
- [PULL 12/20] bsd-user: use qemu_strtoul in preference to strtol,
Warner Losh <=
- [PULL 20/20] bsd-user: rename linux_binprm to bsd_binprm, Warner Losh, 2021/05/12
- Re: [PULL 00/20] bsd-user style tweaks and start cleanup, no-reply, 2021/05/12
- Re: [PULL 00/20] bsd-user style tweaks and start cleanup, Peter Maydell, 2021/05/20