Skip to contentSkip to conversation

exec: Remove dead code (CID 1432876)

RFC Applied Philippe Mathieu-Daudé 2 participants 2 messages Oct 30, 2020 – Oct 31, 2020

lore
Share & tools
lore
#0 lore raw

RFC 1/1 exec: Remove dead code (CID 1432876)

We removed the global_locking field in commit 4174495408a, leaving dead code around the 'unlocked' variable. Remove it to fix the DEADCODE issue reported by Coverity (CID 1432876).

Fixes 4174495408a ("exec: Remove MemoryRegion::global_locking field")
---
 softmmu/physmem.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
softmmu/physmem.c +1 -9
index a9adedb9f82..0b31be29282 100644
@@ -2723,22 +2723,14 @@ static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr)
 
 static bool prepare_mmio_access(MemoryRegion *mr)
 {
-    bool unlocked = !qemu_mutex_iothread_locked();
     bool release_lock = false;
 
-    if (unlocked) {
+    if (!qemu_mutex_iothread_locked()) {
         qemu_mutex_lock_iothread();
-        unlocked = false;
         release_lock = true;
     }
     if (mr->flush_coalesced_mmio) {
-        if (unlocked) {
-            qemu_mutex_lock_iothread();
-        }
         qemu_flush_coalesced_mmio_buffer();
-        if (unlocked) {
-            qemu_mutex_unlock_iothread();
-        }
     }
 
     return release_lock;
Signature · 1 line
2.26.2
#1 lore raw
Quoted 29 lines · Philippe Mathieu-Daudé

We removed the global_locking field in commit 4174495408a, leaving dead code around the 'unlocked' variable. Remove it to fix the DEADCODE issue reported by Coverity (CID 1432876).

Fixes 4174495408a ("exec: Remove MemoryRegion::global_locking field")
---
 softmmu/physmem.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
softmmu/physmem.c +1 -3
index a9adedb9f82..0b31be29282 100644
@@ -2723,22 +2723,14 @@ static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr)
 
 static bool prepare_mmio_access(MemoryRegion *mr)
 {
-    bool unlocked = !qemu_mutex_iothread_locked();
     bool release_lock = false;
 
-    if (unlocked) {
+    if (!qemu_mutex_iothread_locked()) {
         qemu_mutex_lock_iothread();
-        unlocked = false;
         release_lock = true;
     }
     if (mr->flush_coalesced_mmio) {

softmmu/physmem.c static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr) · line 2736

Quoted 10 lines
softmmu/physmem.c +0 -6
-        if (unlocked) {
-            qemu_mutex_lock_iothread();
-        }
         qemu_flush_coalesced_mmio_buffer();
-        if (unlocked) {
-            qemu_mutex_unlock_iothread();
-        }
     }
 
     return release_lock;

Queued, thanks.

Paolo