Skip to contentSkip to conversation

spapr: nested: use bitwise NOT operator for flags check

PATCH In review Harsh Prateek Bora 2 participants 2 messages Mar 29, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spapr: nested: use bitwise NOT operator for flags check

Check for flag bit in H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE need to use bitwise NOT operator to ensure no other flag bits are set. Reported by Coverity as CID 1540008, 1540009.

Signed-off by: Harsh Prateek Bora <[email protected]>

---
 hw/ppc/spapr_nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr_nested.c +1 -1
index 936659b4c0..c02785756c 100644
@@ -1511,7 +1511,7 @@ static target_ulong h_guest_getset_state(PowerPCCPU *cpu,
     if (flags & H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE) {
         gsr.flags |= GUEST_STATE_REQUEST_GUEST_WIDE;
     }
-    if (flags & !H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE) {
+    if (flags & ~H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE) {
         return H_PARAMETER; /* flag not supported yet */
     }
 
Signature · 1 line
2.39.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Harsh Prateek Bora

Check for flag bit in H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE need to use bitwise NOT operator to ensure no other flag bits are set. Reported by Coverity as CID 1540008, 1540009.

Signed-off by: Harsh Prateek Bora <[email protected]>

---
  hw/ppc/spapr_nested.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)