All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: Remove unused assignment (fixes warning from clang)
@ 2013-09-28  9:55 Stefan Weil
  2013-09-29 19:44 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Weil @ 2013-09-28  9:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Kevin Wolf, Stefan Hajnoczi, Stefan Weil

blockdev.c:1929:13: warning: Value stored to 'ret' is never read
            ret = 0;
            ^     ~

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 blockdev.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/blockdev.c b/blockdev.c
index 8aa66a9..8c83f6f 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1926,7 +1926,6 @@ void qmp_drive_mirror(const char *device, const char *target,
     } else {
         switch (mode) {
         case NEW_IMAGE_MODE_EXISTING:
-            ret = 0;
             break;
         case NEW_IMAGE_MODE_ABSOLUTE_PATHS:
             /* create new image with backing file */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] block: Remove unused assignment (fixes warning from clang)
  2013-09-28  9:55 [Qemu-devel] [PATCH] block: Remove unused assignment (fixes warning from clang) Stefan Weil
@ 2013-09-29 19:44 ` Michael Tokarev
  2013-09-29 20:15   ` Stefan Weil
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Tokarev @ 2013-09-29 19:44 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, Kevin Wolf, qemu-devel, Stefan Hajnoczi

28.09.2013 13:55, Stefan Weil wrote:
> blockdev.c:1929:13: warning: Value stored to 'ret' is never read
>              ret = 0;
>              ^     ~

Applied to the trivial patches queue.

> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>   blockdev.c |    1 -
>   1 file changed, 1 deletion(-)
>
> diff --git a/blockdev.c b/blockdev.c
> index 8aa66a9..8c83f6f 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1926,7 +1926,6 @@ void qmp_drive_mirror(const char *device, const char *target,
>       } else {
>           switch (mode) {
>           case NEW_IMAGE_MODE_EXISTING:
> -            ret = 0;
>               break;

While this one is obviously unused assignment,
there's on more usage of `ret' variable in this
function, -- it is to store the return value
from bdrv_open():

     ret = bdrv_open(target_bs, target, NULL, flags | BDRV_O_NO_BACKING, drv,
                     &local_err);
     if (ret < 0) {...

What's the rule about converting that into if() ?

Thanks,

/mjt

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] block: Remove unused assignment (fixes warning from clang)
  2013-09-29 19:44 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
@ 2013-09-29 20:15   ` Stefan Weil
  2013-09-30  7:57     ` Kevin Wolf
  2013-09-30  9:16     ` Stefan Hajnoczi
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Weil @ 2013-09-29 20:15 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: qemu-trivial, Kevin Wolf, qemu-devel, Stefan Hajnoczi

Am 29.09.2013 21:44, schrieb Michael Tokarev:
> 28.09.2013 13:55, Stefan Weil wrote:
[...]
>> diff --git a/blockdev.c b/blockdev.c
>> index 8aa66a9..8c83f6f 100644
>> --- a/blockdev.c
>> +++ b/blockdev.c
>> @@ -1926,7 +1926,6 @@ void qmp_drive_mirror(const char *device, const
>> char *target,
>>       } else {
>>           switch (mode) {
>>           case NEW_IMAGE_MODE_EXISTING:
>> -            ret = 0;
>>               break;
>
> While this one is obviously unused assignment,
> there's on more usage of `ret' variable in this
> function, -- it is to store the return value
> from bdrv_open():
>
>     ret = bdrv_open(target_bs, target, NULL, flags |
> BDRV_O_NO_BACKING, drv,
>                     &local_err);
>     if (ret < 0) {...
>
> What's the rule about converting that into if() ?
>
> Thanks,
>
> /mjt

Is there a rule for cases like that? This pattern is very common in QEMU
code
(several occurrences in blockdev.c). Should we eliminate the 'ret' variable?
I don't think it's worth the effort.

Stefan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] block: Remove unused assignment (fixes warning from clang)
  2013-09-29 20:15   ` Stefan Weil
@ 2013-09-30  7:57     ` Kevin Wolf
  2013-09-30  9:16     ` Stefan Hajnoczi
  1 sibling, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2013-09-30  7:57 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, Michael Tokarev, qemu-devel, Stefan Hajnoczi

Am 29.09.2013 um 22:15 hat Stefan Weil geschrieben:
> Am 29.09.2013 21:44, schrieb Michael Tokarev:
> > 28.09.2013 13:55, Stefan Weil wrote:
> [...]
> >> diff --git a/blockdev.c b/blockdev.c
> >> index 8aa66a9..8c83f6f 100644
> >> --- a/blockdev.c
> >> +++ b/blockdev.c
> >> @@ -1926,7 +1926,6 @@ void qmp_drive_mirror(const char *device, const
> >> char *target,
> >>       } else {
> >>           switch (mode) {
> >>           case NEW_IMAGE_MODE_EXISTING:
> >> -            ret = 0;
> >>               break;
> >
> > While this one is obviously unused assignment,
> > there's on more usage of `ret' variable in this
> > function, -- it is to store the return value
> > from bdrv_open():
> >
> >     ret = bdrv_open(target_bs, target, NULL, flags |
> > BDRV_O_NO_BACKING, drv,
> >                     &local_err);
> >     if (ret < 0) {...
> >
> > What's the rule about converting that into if() ?
> >
> > Thanks,
> >
> > /mjt
> 
> Is there a rule for cases like that? This pattern is very common in QEMU
> code
> (several occurrences in blockdev.c). Should we eliminate the 'ret' variable?
> I don't think it's worth the effort.

And actually I think removing it would make the code worse (less
readable).

Kevin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] block: Remove unused assignment (fixes warning from clang)
  2013-09-29 20:15   ` Stefan Weil
  2013-09-30  7:57     ` Kevin Wolf
@ 2013-09-30  9:16     ` Stefan Hajnoczi
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2013-09-30  9:16 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, Kevin Wolf, Michael Tokarev, qemu-devel

On Sun, Sep 29, 2013 at 10:15:10PM +0200, Stefan Weil wrote:
> Am 29.09.2013 21:44, schrieb Michael Tokarev:
> > 28.09.2013 13:55, Stefan Weil wrote:
> [...]
> >> diff --git a/blockdev.c b/blockdev.c
> >> index 8aa66a9..8c83f6f 100644
> >> --- a/blockdev.c
> >> +++ b/blockdev.c
> >> @@ -1926,7 +1926,6 @@ void qmp_drive_mirror(const char *device, const
> >> char *target,
> >>       } else {
> >>           switch (mode) {
> >>           case NEW_IMAGE_MODE_EXISTING:
> >> -            ret = 0;
> >>               break;
> >
> > While this one is obviously unused assignment,
> > there's on more usage of `ret' variable in this
> > function, -- it is to store the return value
> > from bdrv_open():
> >
> >     ret = bdrv_open(target_bs, target, NULL, flags |
> > BDRV_O_NO_BACKING, drv,
> >                     &local_err);
> >     if (ret < 0) {...
> >
> > What's the rule about converting that into if() ?
> >
> > Thanks,
> >
> > /mjt
> 
> Is there a rule for cases like that? This pattern is very common in QEMU
> code
> (several occurrences in blockdev.c). Should we eliminate the 'ret' variable?
> I don't think it's worth the effort.

Me neither.  There is a minor style difference between putting
everything into the if statement and using a variable to split up a
potentially complicated if statement.

Both approaches are usually okay.

Stefan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-09-30  9:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-28  9:55 [Qemu-devel] [PATCH] block: Remove unused assignment (fixes warning from clang) Stefan Weil
2013-09-29 19:44 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2013-09-29 20:15   ` Stefan Weil
2013-09-30  7:57     ` Kevin Wolf
2013-09-30  9:16     ` Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.