All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 04/11] lsi53c895a: avoid a write only variable
@ 2010-10-06 21:32 Blue Swirl
  2010-10-07  7:20 ` [Qemu-devel] " Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Blue Swirl @ 2010-10-06 21:32 UTC (permalink / raw)
  To: qemu-devel

Compiling with GCC 4.6.0 20100925 produced a warning:
/src/qemu/hw/lsi53c895a.c: In function 'lsi_do_msgout':
/src/qemu/hw/lsi53c895a.c:848:9: error: variable 'len' set but not
used [-Werror=unused-but-set-variable]

Fix by making the variable declaration and its uses also conditional
to debug definition.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 hw/lsi53c895a.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c
index 5eaf69e..db28f06 100644
--- a/hw/lsi53c895a.c
+++ b/hw/lsi53c895a.c
@@ -845,8 +845,9 @@ static uint8_t lsi_get_msgbyte(LSIState *s)
 static void lsi_do_msgout(LSIState *s)
 {
     uint8_t msg;
+#ifdef DEBUG_LSI
     int len;
-
+#endif
     DPRINTF("MSG out len=%d\n", s->dbc);
     while (s->dbc) {
         msg = lsi_get_msgbyte(s);
@@ -862,7 +863,11 @@ static void lsi_do_msgout(LSIState *s)
             lsi_set_phase(s, PHASE_CMD);
             break;
         case 0x01:
+#ifdef DEBUG_LSI
             len = lsi_get_msgbyte(s);
+#else
+            (void)lsi_get_msgbyte(s);
+#endif
             msg = lsi_get_msgbyte(s);
             DPRINTF("Extended message 0x%x (len %d)\n", msg, len);
             switch (msg) {
-- 
1.6.2.4

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

* [Qemu-devel] Re: [PATCH 04/11] lsi53c895a: avoid a write only variable
  2010-10-06 21:32 [Qemu-devel] [PATCH 04/11] lsi53c895a: avoid a write only variable Blue Swirl
@ 2010-10-07  7:20 ` Paolo Bonzini
  2010-10-07  9:20   ` Markus Armbruster
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2010-10-07  7:20 UTC (permalink / raw)
  To: qemu-devel

On 10/06/2010 11:32 PM, Blue Swirl wrote:
> Compiling with GCC 4.6.0 20100925 produced a warning:
> /src/qemu/hw/lsi53c895a.c: In function 'lsi_do_msgout':
> /src/qemu/hw/lsi53c895a.c:848:9: error: variable 'len' set but not
> used [-Werror=unused-but-set-variable]
>
> Fix by making the variable declaration and its uses also conditional
> to debug definition.

NACK, this uglifies the code and loses track of _what_ is that msgbyte 
we're reading.

Paolo

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

* Re: [Qemu-devel] Re: [PATCH 04/11] lsi53c895a: avoid a write only variable
  2010-10-07  7:20 ` [Qemu-devel] " Paolo Bonzini
@ 2010-10-07  9:20   ` Markus Armbruster
  2010-10-07 18:53     ` Blue Swirl
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Armbruster @ 2010-10-07  9:20 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

Paolo Bonzini <pbonzini@redhat.com> writes:

> On 10/06/2010 11:32 PM, Blue Swirl wrote:
>> Compiling with GCC 4.6.0 20100925 produced a warning:
>> /src/qemu/hw/lsi53c895a.c: In function 'lsi_do_msgout':
>> /src/qemu/hw/lsi53c895a.c:848:9: error: variable 'len' set but not
>> used [-Werror=unused-but-set-variable]
>>
>> Fix by making the variable declaration and its uses also conditional
>> to debug definition.
>
> NACK, this uglifies the code and loses track of _what_ is that msgbyte
> we're reading.

Seconded.

If the warning bothers you, maybe "(void)len" can silence it in a less
unsightly manner.

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

* Re: [Qemu-devel] Re: [PATCH 04/11] lsi53c895a: avoid a write only variable
  2010-10-07  9:20   ` Markus Armbruster
@ 2010-10-07 18:53     ` Blue Swirl
  2010-10-08 16:11       ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Blue Swirl @ 2010-10-07 18:53 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Paolo Bonzini, qemu-devel

On Thu, Oct 7, 2010 at 9:20 AM, Markus Armbruster <armbru@redhat.com> wrote:
> Paolo Bonzini <pbonzini@redhat.com> writes:
>
>> On 10/06/2010 11:32 PM, Blue Swirl wrote:
>>> Compiling with GCC 4.6.0 20100925 produced a warning:
>>> /src/qemu/hw/lsi53c895a.c: In function 'lsi_do_msgout':
>>> /src/qemu/hw/lsi53c895a.c:848:9: error: variable 'len' set but not
>>> used [-Werror=unused-but-set-variable]
>>>
>>> Fix by making the variable declaration and its uses also conditional
>>> to debug definition.
>>
>> NACK, this uglifies the code and loses track of _what_ is that msgbyte
>> we're reading.

That information could be saved by adding a comment, I used that
approach for vmstate.c.

>
> Seconded.
>
> If the warning bothers you, maybe "(void)len" can silence it in a less
> unsightly manner.

I'll use that approach next.

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

* Re: [Qemu-devel] Re: [PATCH 04/11] lsi53c895a: avoid a write only variable
  2010-10-07 18:53     ` Blue Swirl
@ 2010-10-08 16:11       ` Paolo Bonzini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2010-10-08 16:11 UTC (permalink / raw)
  To: Blue Swirl; +Cc: Markus Armbruster, qemu-devel

On 10/07/2010 08:53 PM, Blue Swirl wrote:
> On Thu, Oct 7, 2010 at 9:20 AM, Markus Armbruster<armbru@redhat.com>  wrote:
>> Paolo Bonzini<pbonzini@redhat.com>  writes:
>>
>>> On 10/06/2010 11:32 PM, Blue Swirl wrote:
>>>> Compiling with GCC 4.6.0 20100925 produced a warning:
>>>> /src/qemu/hw/lsi53c895a.c: In function 'lsi_do_msgout':
>>>> /src/qemu/hw/lsi53c895a.c:848:9: error: variable 'len' set but not
>>>> used [-Werror=unused-but-set-variable]
>>>>
>>>> Fix by making the variable declaration and its uses also conditional
>>>> to debug definition.
>>>
>>> NACK, this uglifies the code and loses track of _what_ is that msgbyte
>>> we're reading.
>
> That information could be saved by adding a comment, I used that
> approach for vmstate.c.

Yes, that's fine for vmstate.c, but here you are also uselessly 
duplicating the code.  (void) len is good though.  I suggest doing the 
same for i386 too (and there you could put a reference to the manual).

Paolo

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

end of thread, other threads:[~2010-10-08 16:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-06 21:32 [Qemu-devel] [PATCH 04/11] lsi53c895a: avoid a write only variable Blue Swirl
2010-10-07  7:20 ` [Qemu-devel] " Paolo Bonzini
2010-10-07  9:20   ` Markus Armbruster
2010-10-07 18:53     ` Blue Swirl
2010-10-08 16:11       ` Paolo Bonzini

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.