sim/m32r: Initialize "list" variable
authorTsukasa OI <research_trasio@irq.a4lg.com>
Mon, 26 Sep 2022 07:03:00 +0000 (07:03 +0000)
committerTsukasa OI <research_trasio@irq.a4lg.com>
Sat, 29 Oct 2022 08:13:15 +0000 (08:13 +0000)
The variable "list" is only initialized when arg1 > 0 and when arg1 == 0,
an uninitialized value is passed to translate_endian_h2t function.

Although this behavior is harmless, this commit adds initialization to avoid
a GCC warning ("-Wmaybe-uninitialized").

sim/m32r/traps.c

index 267d54881da88aea5c6ca7965c4af02f97bd342f..12a87b4a6978d318e84b90b7450c2cf409d4236c 100644 (file)
@@ -547,7 +547,7 @@ m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num)
          case TARGET_LINUX_SYS_getgroups32:
          case TARGET_LINUX_SYS_getgroups:
            {
-             gid_t *list;
+             gid_t *list = NULL;
 
              if (arg1 > 0)
                list = (gid_t *) malloc (arg1 * sizeof(gid_t));