From nobody Sat May 4 21:53:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500569483241712.5649629141042; Thu, 20 Jul 2017 09:51:23 -0700 (PDT) Received: from localhost ([::1]:39047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYEOe-0001Hv-3A for importer@patchew.org; Thu, 20 Jul 2017 12:33:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYEMq-000095-Vy for qemu-devel@nongnu.org; Thu, 20 Jul 2017 12:32:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYEMp-0007RO-R2 for qemu-devel@nongnu.org; Thu, 20 Jul 2017 12:32:00 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37675) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dYEMp-0007O3-Im; Thu, 20 Jul 2017 12:31:59 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1dYEMM-0007eD-U2; Thu, 20 Jul 2017 17:31:30 +0100 From: Peter Maydell To: qemu-devel@nongnu.org, qemu-trivial@nongnu.org Date: Thu, 20 Jul 2017 17:31:30 +0100 Message-Id: <1500568290-7966-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH for-2.10] Use qemu_tolower() and qemu_toupper(), not tolower() and toupper() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patches@linaro.org, Cornelia Huck , Alexander Graf , Christian Borntraeger , Kamil Rytarowski , qemu-ppc@nongnu.org, Paolo Bonzini , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Acked-by: Christian Borntraeger for the s390 part. Acked-by: David Gibson Reviewed-by: Eric Blake Reviewed-by: Richard Henderson --- 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) =20 cur_action =3D *p++; if (cur_action =3D=3D 'C' || cur_action =3D=3D 'S') { - cur_action =3D tolower(cur_action); + cur_action =3D qemu_tolower(cur_action); res =3D 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 cha= r *val, Error **errp) int i; =20 for (i =3D 0; i < sizeof(ms->loadparm) && val[i]; i++) { - uint8_t c =3D toupper(val[i]); /* mimic HMC */ + uint8_t c =3D qemu_toupper(val[i]); /* mimic HMC */ =20 if (('A' <=3D c && c <=3D 'Z') || ('0' <=3D c && c <=3D '9') || (c= =3D=3D '.') || (c =3D=3D ' ')) { 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_ww= n) } *p_wwn =3D 0; for (i =3D 8; i < 24; i++) { - char c =3D toupper(p[i]); + char c =3D qemu_toupper(p[i]); c -=3D (c >=3D '0' && c <=3D '9' ? '0' : 'A' - 10); *p_wwn =3D (*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 =3D &cpu->env; =20 /* General purpose registers */ - if ((tolower(name[0]) =3D=3D 'r') && + if ((qemu_tolower(name[0]) =3D=3D 'r') && ppc_cpu_get_reg_num(name + 1, ARRAY_SIZE(env->gpr), ®num)) { *pval =3D env->gpr[regnum]; return 0; } =20 /* Floating point registers */ - if ((tolower(name[0]) =3D=3D 'f') && + if ((qemu_tolower(name[0]) =3D=3D 'f') && ppc_cpu_get_reg_num(name + 1, ARRAY_SIZE(env->fpr), ®num)) { *pval =3D env->fpr[regnum]; return 0; --=20 2.7.4