Skip to contentSkip to conversation

Fix erroneous double negation in conditional

PATCH Michael S. Tsirkin 1 participant 1 message May 7, 2020 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 6 lines · Raphael Norwitz

In vhost_migration_log() there is the following check:

    if(!!enable == dev->log_enabled) {
        return 0;
    }

The double negative “!!” is unnecessary and bad coding style.

It converts the value to bool.

Quoted 23 lines

This
change removes it.

---
 hw/virtio/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/vhost.c +1 -1
index aff98a0..83be0c8 100644
@@ -814,7 +814,7 @@ static int vhost_migration_log(MemoryListener *listener, int enable)
     struct vhost_dev *dev = container_of(listener, struct vhost_dev,
                                          memory_listener);
     int r;
-    if (!!enable == dev->log_enabled) {
+    if (enable == dev->log_enabled) {
         return 0;
     }
     if (!dev->started) {
Signature · 1 line
1.8.3.1