From: Richard Henderson Date: Mon, 28 Jul 2025 18:43:35 +0000 (-1000) Subject: linux-user/i386: Return const data from get_elf_platform X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e03b6ad483c087c8cf0357b7859d98bd2b109071;p=thirdparty%2Fqemu.git linux-user/i386: Return const data from get_elf_platform Rather than modify a static buffer, index into an array of const data. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- diff --git a/linux-user/i386/elfload.c b/linux-user/i386/elfload.c index 1b759098ca0..ef3a6c35d20 100644 --- a/linux-user/i386/elfload.c +++ b/linux-user/i386/elfload.c @@ -17,13 +17,9 @@ abi_ulong get_elf_hwcap(CPUState *cs) const char *get_elf_platform(CPUState *cs) { - static char elf_platform[] = "i386"; + static const char elf_platform[4][5] = { "i386", "i486", "i586", "i686" }; int family = object_property_get_int(OBJECT(cs), "family", NULL); - if (family > 6) { - family = 6; - } - if (family >= 3) { - elf_platform[1] = '0' + family; - } - return elf_platform; + + family = MAX(MIN(family, 6), 3); + return elf_platform[family - 3]; }