From: David Gibson <david@gibson.dropbear.id.au>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-trivial@nongnu.org,
patches@linaro.org, Richard Henderson <rth@twiddle.net>,
Alexander Graf <agraf@suse.de>, Cornelia Huck <cohuck@redhat.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Kamil Rytarowski <kamil@netbsd.org>,
qemu-ppc@nongnu.org
Subject: Re: [Qemu-trivial] [PATCH for-2.10] Use qemu_tolower() and qemu_toupper(), not tolower() and toupper()
Date: Fri, 21 Jul 2017 09:58:22 +1000 [thread overview]
Message-ID: <20170720235822.GA3717@umbus.fritz.box> (raw)
In-Reply-To: <1500568290-7966-1-git-send-email-peter.maydell@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 3669 bytes --]
On Thu, Jul 20, 2017 at 05:31:30PM +0100, Peter Maydell wrote:
> On NetBSD, where tolower() and toupper() are implemented using an
> array lookup, the compiler warns if you pass a plain 'char'
> to these functions:
>
> gdbstub.c:914:13: warning: array subscript has type 'char'
>
> This reflects the fact that toupper() and tolower() give
> undefined behaviour if they are passed a value that isn't
> a valid 'unsigned char' or EOF.
>
> We have qemu_tolower() and qemu_toupper() to avoid this problem;
> use them.
>
> (The use in scsi-generic.c does not trigger the warning because
> it passes a uint8_t; we switch it anyway, for consistency.)
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
ppc parts
Acked-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> gdbstub.c | 2 +-
> hw/s390x/s390-virtio-ccw.c | 2 +-
> hw/scsi/scsi-generic.c | 2 +-
> target/ppc/monitor.c | 4 ++--
> 4 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/gdbstub.c b/gdbstub.c
> index f936ddd..2a94030 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -911,7 +911,7 @@ static int gdb_handle_vcont(GDBState *s, const char *p)
>
> cur_action = *p++;
> if (cur_action == 'C' || cur_action == 'S') {
> - cur_action = tolower(cur_action);
> + cur_action = qemu_tolower(cur_action);
> res = qemu_strtoul(p + 1, &p, 16, &tmp);
> if (res) {
> goto out;
> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> index ce3921e..1c7af39 100644
> --- a/hw/s390x/s390-virtio-ccw.c
> +++ b/hw/s390x/s390-virtio-ccw.c
> @@ -318,7 +318,7 @@ static void machine_set_loadparm(Object *obj, const char *val, Error **errp)
> int i;
>
> for (i = 0; i < sizeof(ms->loadparm) && val[i]; i++) {
> - uint8_t c = toupper(val[i]); /* mimic HMC */
> + uint8_t c = qemu_toupper(val[i]); /* mimic HMC */
>
> if (('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || (c == '.') ||
> (c == ' ')) {
> diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
> index a55ff87..7e1cbab 100644
> --- a/hw/scsi/scsi-generic.c
> +++ b/hw/scsi/scsi-generic.c
> @@ -406,7 +406,7 @@ static int read_naa_id(const uint8_t *p, uint64_t *p_wwn)
> }
> *p_wwn = 0;
> for (i = 8; i < 24; i++) {
> - char c = toupper(p[i]);
> + char c = qemu_toupper(p[i]);
> c -= (c >= '0' && c <= '9' ? '0' : 'A' - 10);
> *p_wwn = (*p_wwn << 4) | c;
> }
> diff --git a/target/ppc/monitor.c b/target/ppc/monitor.c
> index b8f30e9..1491511 100644
> --- a/target/ppc/monitor.c
> +++ b/target/ppc/monitor.c
> @@ -115,14 +115,14 @@ int target_get_monitor_def(CPUState *cs, const char *name, uint64_t *pval)
> CPUPPCState *env = &cpu->env;
>
> /* General purpose registers */
> - if ((tolower(name[0]) == 'r') &&
> + if ((qemu_tolower(name[0]) == 'r') &&
> ppc_cpu_get_reg_num(name + 1, ARRAY_SIZE(env->gpr), ®num)) {
> *pval = env->gpr[regnum];
> return 0;
> }
>
> /* Floating point registers */
> - if ((tolower(name[0]) == 'f') &&
> + if ((qemu_tolower(name[0]) == 'f') &&
> ppc_cpu_get_reg_num(name + 1, ARRAY_SIZE(env->fpr), ®num)) {
> *pval = env->fpr[regnum];
> return 0;
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-07-21 0:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-20 16:31 [Qemu-trivial] [PATCH for-2.10] Use qemu_tolower() and qemu_toupper(), not tolower() and toupper() Peter Maydell
2017-07-20 17:57 ` [Qemu-trivial] [Qemu-devel] " Eric Blake
2017-07-20 18:08 ` [Qemu-trivial] " Christian Borntraeger
2017-07-20 18:26 ` Richard Henderson
2017-07-20 18:48 ` [Qemu-trivial] [Qemu-devel] " Eric Blake
2017-07-20 18:57 ` Richard Henderson
2017-07-20 19:04 ` Eric Blake
2017-07-20 19:14 ` Richard Henderson
2017-07-20 21:03 ` [Qemu-trivial] " Peter Maydell
2017-07-20 21:29 ` [Qemu-trivial] [Qemu-devel] " Eric Blake
2017-07-20 21:42 ` Peter Maydell
2017-07-20 23:58 ` David Gibson [this message]
2017-07-21 10:23 ` Peter Maydell
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=20170720235822.GA3717@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=kamil@netbsd.org \
--cc=patches@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=rth@twiddle.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).