Commit 36212b4e85 for qemu.org

commit 36212b4e859d1ccb25ab37deac152d67421ac425
Author: Peter Maydell <peter.maydell@linaro.org>
Date:   Mon Mar 30 16:18:07 2026 +0100

    hw/arm/xilinx_zynq: Use strcasecmp to parse boot-mode option values

    In zynq_set_boot_mode() where we parse the string the user has set
    the boot-mode option to, we use strncasecmp(str, "qspi", 4) and so
    on.  This is wrong, because it means that we will ignore any trailing
    junk on the end of the option string, and handle
     -machine boot-mode=sdXYZZY
    the same as
     -machine boot-mode=sd

    In the documentation we say:
     Supported values are ``jtag``, ``sd``, ``qspi`` and ``nor``.
    and that's obviously what we meant to implement.

    The correct tool for this job is a simple strcasecmp operation.
    Switch to that.

    We use the g_ascii_strcasecmp() rather than plain strcasecmp()
    because we're comparing ASCII strings here and don't want the
    potentially locale-specific behaviour that strcasecmp() implies (and
    we're trying to standardize on the glib function for this kind of
    string comparison).

    Fixes: 7df3747c92d13 ("hw/arm/xilinx_zynq: Add boot-mode property")
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
    Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
    Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
    Message-id: 20260327145012.907264-1-peter.maydell@linaro.org

diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index d43f36b718..9dcded9219 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -186,13 +186,13 @@ static void zynq_set_boot_mode(Object *obj, const char *str,
     ZynqMachineState *m = ZYNQ_MACHINE(obj);
     uint8_t mode = 0;

-    if (!strncasecmp(str, "qspi", 4)) {
+    if (!g_ascii_strcasecmp(str, "qspi")) {
         mode = 1;
-    } else if (!strncasecmp(str, "sd", 2)) {
+    } else if (!g_ascii_strcasecmp(str, "sd")) {
         mode = 5;
-    } else if (!strncasecmp(str, "nor", 3)) {
+    } else if (!g_ascii_strcasecmp(str, "nor")) {
         mode = 2;
-    } else if (!strncasecmp(str, "jtag", 4)) {
+    } else if (!g_ascii_strcasecmp(str, "jtag")) {
         mode = 0;
     } else {
         error_setg(errp, "%s boot mode not supported", str);