Patchwork [2/2] scsi: fix warning

login
register
mail settings
Submitter Gerd Hoffmann
Date Aug. 10, 2012, 1:26 p.m.
Message ID <1344605205-28583-3-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/176493/
State New
Headers show

Comments

Gerd Hoffmann - Aug. 10, 2012, 1:26 p.m.
hw/scsi-bus.c:758: warning: ‘xfer’ may be used uninitialized in this
function

Isn't true, but older gcc versions (for example 4.1 as shipped in rhel5)
are not clever enougth to figure, so sprinkle in a default: line to make
them happy.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/scsi-bus.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Paolo Bonzini - Aug. 10, 2012, 1:51 p.m.
Il 10/08/2012 15:26, Gerd Hoffmann ha scritto:
> hw/scsi-bus.c:758: warning: ‘xfer’ may be used uninitialized in this
> function
> 
> Isn't true, but older gcc versions (for example 4.1 as shipped in rhel5)
> are not clever enougth to figure, so sprinkle in a default: line to make
> them happy.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  hw/scsi-bus.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
> index b8a857d..4981a02 100644
> --- a/hw/scsi-bus.c
> +++ b/hw/scsi-bus.c
> @@ -761,6 +761,7 @@ static int ata_passthrough_12_xfer_size(SCSIDevice *dev, uint8_t *buf)
>      switch (length) {
>      case 0:
>      case 3: /* USB-specific.  */
> +    default:
>          xfer = 0;
>          break;
>      case 1:
> @@ -784,6 +785,7 @@ static int ata_passthrough_16_xfer_size(SCSIDevice *dev, uint8_t *buf)
>      switch (length) {
>      case 0:
>      case 3: /* USB-specific.  */
> +    default:
>          xfer = 0;
>          break;
>      case 1:
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo

Patch

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index b8a857d..4981a02 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -761,6 +761,7 @@  static int ata_passthrough_12_xfer_size(SCSIDevice *dev, uint8_t *buf)
     switch (length) {
     case 0:
     case 3: /* USB-specific.  */
+    default:
         xfer = 0;
         break;
     case 1:
@@ -784,6 +785,7 @@  static int ata_passthrough_16_xfer_size(SCSIDevice *dev, uint8_t *buf)
     switch (length) {
     case 0:
     case 3: /* USB-specific.  */
+    default:
         xfer = 0;
         break;
     case 1: