Skip to contentSkip to conversation

virtio-mem: silence a static checker warning

PATCH Applied Dan Carpenter 3 participants 3 messages Jun 10, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-mem: silence a static checker warning

Smatch complains that "rc" can be uninitialized if we hit the "break;" statement on the first iteration through the loop. I suspect that this can't happen in real life, but returning a zero literal is cleaner and silence the static checker warning.

---
 drivers/virtio/virtio_mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio_mem.c +1 -1
index f658fe9149beb..893ef18060a02 100644
@@ -1192,7 +1192,7 @@ static int virtio_mem_mb_plug_any_sb(struct virtio_mem *vm, unsigned long mb_id,
 						VIRTIO_MEM_MB_STATE_OFFLINE);
 	}
 
-	return rc;
+	return 0;
 }
 
 /*
Signature · 1 line
2.26.2
maintainer Applied
#1 lore raw
Quoted 9 lines · Dan Carpenter

Smatch complains that "rc" can be uninitialized if we hit the "break;" statement on the first iteration through the loop. I suspect that this can't happen in real life, but returning a zero literal is cleaner and silence the static checker warning.

---
 drivers/virtio/virtio_mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Quoted 15 lines
drivers/virtio/virtio_mem.c +1 -1
index f658fe9149beb..893ef18060a02 100644
@@ -1192,7 +1192,7 @@ static int virtio_mem_mb_plug_any_sb(struct virtio_mem *vm, unsigned long mb_id,
 						VIRTIO_MEM_MB_STATE_OFFLINE);
 	}
 
-	return rc;
+	return 0;
 }
 
 /*
Signature · 1 line
2.26.2
Acked-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 9 lines

Am 10.06.2020 um 10:59 schrieb Dan Carpenter <[email protected]>:

Smatch complains that "rc" can be uninitialized if we hit the "break;" statement on the first iteration through the loop. I suspect that this can't happen in real life, but returning a zero literal is cleaner and silence the static checker warning.

Right, it‘s impossible in real life. Thanks!

Quoted 21 lines

---
drivers/virtio/virtio_mem.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio_mem.c +1 -1
index f658fe9149beb..893ef18060a02 100644
@@ -1192,7 +1192,7 @@ static int virtio_mem_mb_plug_any_sb(struct virtio_mem *vm, unsigned long mb_id,
                       VIRTIO_MEM_MB_STATE_OFFLINE);
   }
 
-    return rc;
+    return 0;
 }
 
 /*
Signature · 1 line
2.26.2