[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 7/8] semihosting: clean up handling of expanded argv
From: |
Alex Bennée |
Subject: |
[PATCH v1 7/8] semihosting: clean up handling of expanded argv |
Date: |
Tue, 15 Mar 2022 12:12:50 +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>
---
semihosting/config.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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
- [PATCH for 7.0 v1 0/8] misc testing, i386, docs, gitdm, gitlab, Alex Bennée, 2022/03/15
- [PATCH v1 1/8] tests/Makefile.include: Let "make clean" remove the TCG tests, too, Alex Bennée, 2022/03/15
- [PATCH v1 4/8] tests/tcg: drop -cpu max from s390x sha512-mvx invocation, Alex Bennée, 2022/03/15
- [PATCH v1 2/8] tests/avocado: update aarch64_virt test to exercise -cpu max, Alex Bennée, 2022/03/15
- [PATCH v1 3/8] target/i386: force maximum rounding precision for fildl[l], Alex Bennée, 2022/03/15
- [PATCH v1 6/8] docs/devel: try and impose some organisation, Alex Bennée, 2022/03/15
- [PATCH v1 7/8] semihosting: clean up handling of expanded argv,
Alex Bennée <=
[PATCH v1 5/8] mailmap/gitdm: more fixes for bad tags and authors, Alex Bennée, 2022/03/15
[PATCH v1 8/8] gitlab: include new aarch32 job in custom-runners, Alex Bennée, 2022/03/15
Re: [PATCH for 7.0 v1 0/8] misc testing, i386, docs, gitdm, gitlab, Alex Bennée, 2022/03/21