From: Mike Frysinger Date: Sat, 6 Nov 2021 17:19:35 +0000 (-0400) Subject: sim: sh: fix uninitialized variable usage with pdmsb X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=524d770c9c127e077f59f0b2adadc9c14d003e0a;p=binutils-gdb.git sim: sh: fix uninitialized variable usage with pdmsb This block of code relies on i to control which bits to test and how many times to run through the loop, but it never actually initialized it. There is another chunk of code that handles the pdmsb instruction that sets i to 16, so use that here too assuming it's correct. The programming manual suggests this is the right value too, but I am by no means a SuperH DSP expert. The tests are still passing though ... --- diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c index 9ef8b4610be..80eecfdf1d3 100644 --- a/sim/sh/gencode.c +++ b/sim/sh/gencode.c @@ -2363,7 +2363,7 @@ op ppi_tab[] = }, { "","", "(if cc) pdmsb Sy,Dz", "101111cc..yyzzzz", "unsigned Sy = DSP_R (y);", - "int i;", + "int i = 16;", "", "if (Sy < 0)", " Sy = ~Sy;",