[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 5/8] semihosting: clean up handling of expanded argv
From: |
Alex Bennée |
Subject: |
[PULL 5/8] semihosting: clean up handling of expanded argv |
Date: |
Wed, 23 Mar 2022 11:27:08 +0000 |
Another cleanup patch tripped over the fact we weren't being careful
in our casting. Fix the casts, allow for a non-const and switch from
g_realloc to g_renew.
The whole semihosting argument handling could do with some tests
though.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220315121251.2280317-8-alex.bennee@linaro.org>
diff --git a/semihosting/config.c b/semihosting/config.c
index 137171b717..50d82108e6 100644
--- a/semihosting/config.c
+++ b/semihosting/config.c
@@ -51,7 +51,7 @@ typedef struct SemihostingConfig {
bool enabled;
SemihostingTarget target;
Chardev *chardev;
- const char **argv;
+ char **argv;
int argc;
const char *cmdline; /* concatenated argv */
} SemihostingConfig;
@@ -98,8 +98,8 @@ static int add_semihosting_arg(void *opaque,
if (strcmp(name, "arg") == 0) {
s->argc++;
/* one extra element as g_strjoinv() expects NULL-terminated array */
- s->argv = g_realloc(s->argv, (s->argc + 1) * sizeof(void *));
- s->argv[s->argc - 1] = val;
+ s->argv = g_renew(char *, s->argv, s->argc + 1);
+ s->argv[s->argc - 1] = g_strdup(val);
s->argv[s->argc] = NULL;
}
return 0;
--
2.30.2
- [PULL for 7.0 0/8] i386, docs, gitlab fixes, Alex Bennée, 2022/03/23
- [PULL 1/8] tests/Makefile.include: Let "make clean" remove the TCG tests, too, Alex Bennée, 2022/03/23
- [PULL 3/8] mailmap/gitdm: more fixes for bad tags and authors, Alex Bennée, 2022/03/23
- [PULL 2/8] target/i386: force maximum rounding precision for fildl[l], Alex Bennée, 2022/03/23
- [PULL 5/8] semihosting: clean up handling of expanded argv,
Alex Bennée <=
- [PULL 4/8] docs/devel: try and impose some organisation, Alex Bennée, 2022/03/23
- [PULL 6/8] gitlab: include new aarch32 job in custom-runners, Alex Bennée, 2022/03/23
- [PULL 8/8] docs/tcg-plugins: document QEMU_PLUGIN behaviour, Alex Bennée, 2022/03/23
- [PULL 7/8] docs: remove qemu_logo.pdf, Alex Bennée, 2022/03/23
- Re: [PULL for 7.0 0/8] i386, docs, gitlab fixes, Peter Maydell, 2022/03/23
- Re: [PULL for 7.0 0/8] i386, docs, gitlab fixes, Peter Maydell, 2022/03/24