* [PATCH] virtio-mem: silence a static checker warning
@ 2020-06-10 8:59 Dan Carpenter
2020-06-10 9:39 ` Michael S. Tsirkin
2020-06-10 9:43 ` David Hildenbrand
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2020-06-10 8:59 UTC (permalink / raw)
To: David Hildenbrand
Cc: virtualization, kernel-janitors, linux-kernel, Michael S. Tsirkin
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.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/virtio/virtio_mem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
index f658fe9149beb..893ef18060a02 100644
--- a/drivers/virtio/virtio_mem.c
+++ b/drivers/virtio/virtio_mem.c
@@ -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;
}
/*
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] virtio-mem: silence a static checker warning
2020-06-10 8:59 [PATCH] virtio-mem: silence a static checker warning Dan Carpenter
@ 2020-06-10 9:39 ` Michael S. Tsirkin
2020-06-10 9:43 ` David Hildenbrand
1 sibling, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2020-06-10 9:39 UTC (permalink / raw)
To: Dan Carpenter
Cc: David Hildenbrand, Jason Wang, virtualization, linux-kernel,
kernel-janitors
On Wed, Jun 10, 2020 at 11:59:11AM +0300, Dan Carpenter wrote:
> 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.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/virtio/virtio_mem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
> diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
> index f658fe9149beb..893ef18060a02 100644
> --- a/drivers/virtio/virtio_mem.c
> +++ b/drivers/virtio/virtio_mem.c
> @@ -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;
> }
>
> /*
> --
> 2.26.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] virtio-mem: silence a static checker warning
2020-06-10 8:59 [PATCH] virtio-mem: silence a static checker warning Dan Carpenter
2020-06-10 9:39 ` Michael S. Tsirkin
@ 2020-06-10 9:43 ` David Hildenbrand
1 sibling, 0 replies; 3+ messages in thread
From: David Hildenbrand @ 2020-06-10 9:43 UTC (permalink / raw)
To: Dan Carpenter
Cc: David Hildenbrand, Michael S. Tsirkin, Jason Wang, virtualization,
linux-kernel, kernel-janitors
> Am 10.06.2020 um 10:59 schrieb Dan Carpenter <dan.carpenter@oracle.com>:
>
> 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!
Acked-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/virtio/virtio_mem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
> index f658fe9149beb..893ef18060a02 100644
> --- a/drivers/virtio/virtio_mem.c
> +++ b/drivers/virtio/virtio_mem.c
> @@ -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;
> }
>
> /*
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-10 9:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-10 8:59 [PATCH] virtio-mem: silence a static checker warning Dan Carpenter
2020-06-10 9:39 ` Michael S. Tsirkin
2020-06-10 9:43 ` David Hildenbrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).