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 | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/linux-user/i386/elfload.c b/linux-user/i386/elfload.c
index 1b759098ca..ef3a6c35d2 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];
}
--
2.43.0