[12/40] sim/frv: Initialize nesr variable

Message ID 021dbd238af5dfe74523ed229d2156a155a6bb9e.1666258361.git.research_trasio@irq.a4lg.com
State Committed
Headers
Series sim+gdb: Suppress warnings if built with Clang (big batch 1) |

Commit Message

Tsukasa OI Oct. 20, 2022, 9:32 a.m. UTC
  GCC generates a warning if a variable may be used uninitialized on some
cases ("-Wmaybe-uninitialized").  Despite that GCC will not cause a build
failure even when "--enable-werror" is specified, it would be nice to get
rid of it.

This commit initializes the variable nesr when declared.
---
 sim/frv/traps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Mike Frysinger Oct. 23, 2022, 2:39 p.m. UTC | #1
On 20 Oct 2022 09:32, Tsukasa OI wrote:
> GCC generates a warning if a variable may be used uninitialized on some
> cases ("-Wmaybe-uninitialized").  Despite that GCC will not cause a build
> failure even when "--enable-werror" is specified, it would be nice to get
> rid of it.
> 
> This commit initializes the variable nesr when declared.

afaict, the code as written is not using nesr uninitialized (well, it does,
but not in a way that changes behavior in the func, or is exposed out).  so
this looks fine because setting it to 0 initially in those cases also does
not change behavior.

i'm not familiar enough with FRV to say if pulling nesr from a diff place
would be more safe to future code refactors.  but since this port seems to
largely be stable at this point, this is probably fine.
-mike
  

Patch

diff --git a/sim/frv/traps.c b/sim/frv/traps.c
index 0c9eacd0bfd..b142c7890ad 100644
--- a/sim/frv/traps.c
+++ b/sim/frv/traps.c
@@ -432,7 +432,7 @@  frvbf_check_non_excepting_load (
   int do_elos;
   SI NE_flags[2];
   SI NE_base;
-  SI nesr;
+  SI nesr = 0;
   SI ne_index;
   FRV_REGISTER_CONTROL *control;