Skip to contentSkip to conversation

ide/atapi: fix set but unused

PATCH Superseded Alon Levy 4 participants 7 messages Apr 28, 2011 – Apr 29, 2011

lore
Share & tools
lore

Alon Levy

author
#0 lore raw

PATCH 1/1 ide/atapi: fix set but unused

---
 hw/ide/atapi.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
hw/ide/atapi.c +3 -1
index 690a0ab..81fa01b 100644
@@ -1080,12 +1080,14 @@ static const struct {
 
 void ide_atapi_cmd(IDEState *s)
 {
+#ifdef DEBUG_IDE_ATAPI
     const uint8_t *packet;
+#endif
     uint8_t *buf;
 
-    packet = s->io_buffer;
     buf = s->io_buffer;
 #ifdef DEBUG_IDE_ATAPI
+    packet = s->io_buffer;
     {
         int i;
         printf("ATAPI limit=0x%x packet:", s->lcyl | (s->hcyl << 8));
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 15 lines · Alon Levy
---
  hw/ide/atapi.c |    4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)
hw/ide/atapi.c +1 -0
index 690a0ab..81fa01b 100644
@@ -1080,12 +1080,14 @@ static const struct {
 
  void ide_atapi_cmd(IDEState *s)
  {
+#ifdef DEBUG_IDE_ATAPI
      const uint8_t *packet;

hw/ide/atapi.c static const struct { · line 1093

Quoted 10 lines
hw/ide/atapi.c +2 -1
+#endif
      uint8_t *buf;
 
-    packet = s->io_buffer;
      buf = s->io_buffer;
  #ifdef DEBUG_IDE_ATAPI
+    packet = s->io_buffer;
      {
          int i;
          printf("ATAPI limit=0x%x packet:", s->lcyl | (s->hcyl<<  8));

ACK

... but why don't we allow interspersing declarations and statements? There are already so many C99 and GCC extensions in use in QEMU.

Paolo

#2 lore raw

Am 28.04.2011 14:07, schrieb Paolo Bonzini:

Quoted 29 lines · Alon Levy
Quoted 15 lines
---
  hw/ide/atapi.c |    4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)
hw/ide/atapi.c +1 -0
index 690a0ab..81fa01b 100644
@@ -1080,12 +1080,14 @@ static const struct {
 
  void ide_atapi_cmd(IDEState *s)
  {
+#ifdef DEBUG_IDE_ATAPI
      const uint8_t *packet;

hw/ide/atapi.c static const struct { · line 1093

Quoted 10 lines
hw/ide/atapi.c +2 -1
+#endif
      uint8_t *buf;
 
-    packet = s->io_buffer;
      buf = s->io_buffer;
  #ifdef DEBUG_IDE_ATAPI
+    packet = s->io_buffer;
      {
          int i;
          printf("ATAPI limit=0x%x packet:", s->lcyl | (s->hcyl<<  8));

ACK

Quoted 3 lines

... but why don't we allow interspersing declarations and statements? There are already so many C99 and GCC extensions in use in QEMU.

Paolo

What about using buf instead of packet (no need for extensions, reduces code by 4 lines)?

Stefan W.

#3 lore raw
Quoted 3 lines · Stefan Weil

What about using buf instead of packet (no need for extensions, reduces code by 4 lines)?

Uh, you're right!... I was assuming some side effect later, but after the refactoring this is indeed the only place where packet is used in the function, and it could use buf.

Paolo

author
#4 lore raw

PATCH v2 1/1 ide/atapi: fix set but unused

---
 hw/ide/atapi.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
hw/ide/atapi.c +1 -3
index 690a0ab..0073c8d 100644
@@ -1080,17 +1080,15 @@ static const struct {
 
 void ide_atapi_cmd(IDEState *s)
 {
-    const uint8_t *packet;
     uint8_t *buf;
 
-    packet = s->io_buffer;
     buf = s->io_buffer;
 #ifdef DEBUG_IDE_ATAPI
     {
         int i;
         printf("ATAPI limit=0x%x packet:", s->lcyl | (s->hcyl << 8));
         for(i = 0; i < ATAPI_PACKET_SIZE; i++) {
-            printf(" %02x", packet[i]);
+            printf(" %02x", buf[i]);
         }
         printf("\n");
     }
Signature · 1 line
1.7.4.4
Acked-by on v2 1/1
#5 lore raw

Am 28.04.2011 15:34, schrieb Alon Levy:

Quoted 19 lines
---
  hw/ide/atapi.c |    4 +---
  1 files changed, 1 insertions(+), 3 deletions(-)
hw/ide/atapi.c +0 -2
index 690a0ab..0073c8d 100644
@@ -1080,17 +1080,15 @@ static const struct {
 
  void ide_atapi_cmd(IDEState *s)
  {
-    const uint8_t *packet;
      uint8_t *buf;
 
-    packet = s->io_buffer;
      buf = s->io_buffer;

hw/ide/atapi.c static const struct { · line 1094

Quoted 10 lines
hw/ide/atapi.c +1 -1
  #ifdef DEBUG_IDE_ATAPI
      {
          int i;
          printf("ATAPI limit=0x%x packet:", s->lcyl | (s->hcyl<<  8));
          for(i = 0; i<  ATAPI_PACKET_SIZE; i++) {
-            printf(" %02x", packet[i]);
+            printf(" %02x", buf[i]);
          }
          printf("\n");
      }