[PATCH 19/40] sim/m32r: Initialize "list" variable

Tsukasa OI research_trasio@irq.a4lg.com
Thu Oct 20 09:32:24 GMT 2022


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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sim/m32r/traps.c b/sim/m32r/traps.c
index 267d54881da..12a87b4a697 100644
--- a/sim/m32r/traps.c
+++ b/sim/m32r/traps.c
@@ -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));
-- 
2.34.1



More information about the Gdb-patches mailing list