From: "Philippe Mathieu-Daudé" <philippe.mathieu.daude@gmail.com>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Cc: fam@euphon.net, berrange@redhat.com, f4bug@amsat.org,
aurelien@aurel32.net, pbonzini@redhat.com, stefanha@redhat.com,
crosa@redhat.com, qemu-arm@nongnu.org,
richard.henderson@linaro.org, sw@weilnetz.de
Subject: Re: [PATCH v1 7/8] semihosting: clean up handling of expanded argv
Date: Tue, 15 Mar 2022 13:31:26 +0100 [thread overview]
Message-ID: <6c7bdb98-ad58-e48e-caa5-a9747b8ad90b@gmail.com> (raw)
In-Reply-To: <20220315121251.2280317-8-alex.bennee@linaro.org>
On 15/3/22 13:12, Alex Bennée wrote:
> 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);
Why strdup()?
> s->argv[s->argc] = NULL;
> }
> return 0;
WARNING: multiple messages have this Message-ID (diff)
From: "Philippe Mathieu-Daudé" <philippe.mathieu.daude@gmail.com>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Cc: fam@euphon.net, berrange@redhat.com, sw@weilnetz.de,
richard.henderson@linaro.org, f4bug@amsat.org,
qemu-arm@nongnu.org, stefanha@redhat.com, crosa@redhat.com,
pbonzini@redhat.com, aurelien@aurel32.net
Subject: Re: [PATCH v1 7/8] semihosting: clean up handling of expanded argv
Date: Tue, 15 Mar 2022 13:31:26 +0100 [thread overview]
Message-ID: <6c7bdb98-ad58-e48e-caa5-a9747b8ad90b@gmail.com> (raw)
In-Reply-To: <20220315121251.2280317-8-alex.bennee@linaro.org>
On 15/3/22 13:12, Alex Bennée wrote:
> 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);
Why strdup()?
> s->argv[s->argc] = NULL;
> }
> return 0;
next prev parent reply other threads:[~2022-03-15 12:31 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-15 12:12 [PATCH for 7.0 v1 0/8] misc testing, i386, docs, gitdm, gitlab Alex Bennée
2022-03-15 12:12 ` Alex Bennée
2022-03-15 12:12 ` [PATCH v1 1/8] tests/Makefile.include: Let "make clean" remove the TCG tests, too Alex Bennée
2022-03-15 12:12 ` Alex Bennée
2022-03-15 12:12 ` [PATCH v1 2/8] tests/avocado: update aarch64_virt test to exercise -cpu max Alex Bennée
2022-03-15 12:12 ` Alex Bennée
2022-03-21 17:10 ` Thomas Huth
2022-03-22 16:49 ` Richard Henderson
2022-03-22 16:49 ` Richard Henderson
2022-03-15 12:12 ` [PATCH v1 3/8] target/i386: force maximum rounding precision for fildl[l] Alex Bennée
2022-03-15 12:12 ` Alex Bennée
2022-03-15 12:12 ` [PATCH v1 4/8] tests/tcg: drop -cpu max from s390x sha512-mvx invocation Alex Bennée
2022-03-15 12:12 ` Alex Bennée
2022-03-15 12:12 ` [PATCH v1 5/8] mailmap/gitdm: more fixes for bad tags and authors Alex Bennée
2022-03-15 12:12 ` Alex Bennée
2022-03-16 8:23 ` Michael Ellerman
2022-03-16 8:23 ` Michael Ellerman
2022-03-15 12:12 ` [PATCH v1 6/8] docs/devel: try and impose some organisation Alex Bennée
2022-03-15 12:12 ` Alex Bennée
2022-03-15 12:12 ` [PATCH v1 7/8] semihosting: clean up handling of expanded argv Alex Bennée
2022-03-15 12:12 ` Alex Bennée
2022-03-15 12:31 ` Philippe Mathieu-Daudé [this message]
2022-03-15 12:31 ` Philippe Mathieu-Daudé
2022-03-15 13:59 ` Alex Bennée
2022-03-15 13:59 ` Alex Bennée
2022-03-15 14:15 ` Daniel P. Berrangé
2022-03-15 14:15 ` Daniel P. Berrangé
2022-03-15 14:20 ` Peter Maydell
2022-03-15 14:20 ` Peter Maydell
2022-03-21 21:55 ` Philippe Mathieu-Daudé
2022-03-21 21:55 ` Philippe Mathieu-Daudé
2022-03-15 12:12 ` [PATCH v1 8/8] gitlab: include new aarch32 job in custom-runners Alex Bennée
2022-03-15 12:12 ` Alex Bennée
2022-03-15 12:19 ` Alex Bennée
2022-03-15 12:19 ` Alex Bennée
2022-03-15 12:19 ` [PATCH v2] " Alex Bennée
2022-03-15 12:34 ` Philippe Mathieu-Daudé
2022-03-15 21:48 ` Richard Henderson
2022-03-21 16:46 ` [PATCH for 7.0 v1 0/8] misc testing, i386, docs, gitdm, gitlab Alex Bennée
2022-03-21 16:46 ` Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6c7bdb98-ad58-e48e-caa5-a9747b8ad90b@gmail.com \
--to=philippe.mathieu.daude@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=aurelien@aurel32.net \
--cc=berrange@redhat.com \
--cc=crosa@redhat.com \
--cc=f4bug@amsat.org \
--cc=fam@euphon.net \
--cc=pbonzini@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.com \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.