aboutsummaryrefslogtreecommitdiff
path: root/semihosting/config.c
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2022-03-15 11:46:12 +0000
committerAlex Bennée <alex.bennee@linaro.org>2022-03-23 10:38:09 +0000
commit78beee809d49adc0862c89816d72ece57c3913b7 (patch)
tree811b17d15737171882008862b0fd5a36f722d743 /semihosting/config.c
parentc6afd2bdfd69e9a8d2c0c7c41aac5255e34a60bc (diff)
downloadqemu-78beee809d49adc0862c89816d72ece57c3913b7.zip
qemu-78beee809d49adc0862c89816d72ece57c3913b7.tar.gz
qemu-78beee809d49adc0862c89816d72ece57c3913b7.tar.bz2
semihosting: clean up handling of expanded argv
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>
Diffstat (limited to 'semihosting/config.c')
-rw-r--r--semihosting/config.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/semihosting/config.c b/semihosting/config.c
index 137171b..50d8210 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;