]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
linux-user/i386: Return const data from get_elf_platform
authorRichard Henderson <richard.henderson@linaro.org>
Mon, 28 Jul 2025 18:43:35 +0000 (08:43 -1000)
committerRichard Henderson <richard.henderson@linaro.org>
Wed, 27 Aug 2025 20:39:25 +0000 (06:39 +1000)
Rather than modify a static buffer, index into an array of const data.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
linux-user/i386/elfload.c

index 1b759098ca0e63cdfdf2b0bdc691ede72c787c55..ef3a6c35d20e9ae81715111d87643ab0ff14023c 100644 (file)
@@ -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];
 }