Skip to contentSkip to conversation

hw/misc/iotkit-secctl: Fix writing to 'PPC Interrupt Clear' register

PATCH Superseded Philippe Mathieu-Daudé 2 participants 3 messages Feb 17, 2020

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hw/misc/iotkit-secctl: Fix writing to 'PPC Interrupt Clear' register

Fix warning reported by Clang static code analyzer:

CC hw/misc/iotkit-secctl.o
hw/misc/iotkit-secctl.c:343:9: warning: Value stored to 'value' is never read

          value &= 0x00f000f3;
          ^        ~~~~~~~~~~
Fixes b3717c23e1c
Reported-by Clang Static Analyzer

---
v2: Corrected bitwise-not precedence (pm215)

---
 hw/misc/iotkit-secctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/iotkit-secctl.c +1 -1
index 609869821a..43cf0f9970 100644
@@ -340,7 +340,7 @@ static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr,
         qemu_set_irq(s->sec_resp_cfg, s->secrespcfg);
         break;
     case A_SECPPCINTCLR:
-        value &= 0x00f000f3;
+        s->secppcintstat = ~(value & 0x00f000f3);
         foreach_ppc(s, iotkit_secctl_ppc_update_irq_clear);
         break;
     case A_SECPPCINTEN:
Signature · 1 line
2.21.1
#1 lore raw
Quoted 22 lines · Philippe Mathieu-Daudé

Fix warning reported by Clang static code analyzer:

CC hw/misc/iotkit-secctl.o
hw/misc/iotkit-secctl.c:343:9: warning: Value stored to 'value' is never read

          value &= 0x00f000f3;
          ^        ~~~~~~~~~~
Fixes b3717c23e1c
Reported-by Clang Static Analyzer

---
v2: Corrected bitwise-not precedence (pm215)

---
 hw/misc/iotkit-secctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/misc/iotkit-secctl.c +0 -0
index 609869821a..43cf0f9970 100644

hw/misc/iotkit-secctl.c static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr, · line 343

Quoted 5 lines
hw/misc/iotkit-secctl.c +1 -1
@@ -340,7 +340,7 @@ static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr,
         qemu_set_irq(s->sec_resp_cfg, s->secrespcfg);
         break;
     case A_SECPPCINTCLR:
-        value &= 0x00f000f3;
+        s->secppcintstat = ~(value & 0x00f000f3);

Should be &=, not =. Otherwise you set all the other bits in the register.

thanks
-- PMM

#2 lore raw
Quoted 18 lines · Peter Maydell
Quoted 17 lines · Philippe Mathieu-Daudé

Fix warning reported by Clang static code analyzer:

CC hw/misc/iotkit-secctl.o
hw/misc/iotkit-secctl.c:343:9: warning: Value stored to 'value' is never read

          value &= 0x00f000f3;
          ^        ~~~~~~~~~~
Fixes b3717c23e1c
Reported-by Clang Static Analyzer

---
v2: Corrected bitwise-not precedence (pm215)

---
 hw/misc/iotkit-secctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines

hw/misc/iotkit-secctl.c static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr, · line 343

Quoted 10 lines
hw/misc/iotkit-secctl.c +1 -1
index 609869821a..43cf0f9970 100644
@@ -340,7 +340,7 @@ static MemTxResult iotkit_secctl_s_write(void *opaque, hwaddr addr,
         qemu_set_irq(s->sec_resp_cfg, s->secrespcfg);
         break;
     case A_SECPPCINTCLR:
-        value &= 0x00f000f3;
+        s->secppcintstat = ~(value & 0x00f000f3);

Should be &=, not =. Otherwise you set all the other bits in the register.

Yes, I'm sorry.