Patchwork hw: Disable code after return statement

login
register
mail settings
Submitter Stefan Weil
Date Sept. 23, 2012, 6:41 a.m.
Message ID <1348382492-8342-1-git-send-email-sw@weilnetz.de>
Download mbox | patch
Permalink /patch/186183/
State Under Review
Headers show

Comments

Stefan Weil - Sept. 23, 2012, 6:41 a.m.
Report from smatch:
microdrive.c:212 md_common_read(34) info: ignoring unreachable code.
microdrive.c:273 md_common_write(33) info: ignoring unreachable code.
sd.c:343 sd_req_crc_validate(9) info: ignoring unreachable code.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 hw/ide/microdrive.c |    3 ++-
 hw/sd.c             |    2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
Stefan Hajnoczi - Oct. 5, 2012, 11:53 a.m.
On Sun, Sep 23, 2012 at 08:41:32AM +0200, Stefan Weil wrote:
> Report from smatch:
> microdrive.c:212 md_common_read(34) info: ignoring unreachable code.
> microdrive.c:273 md_common_write(33) info: ignoring unreachable code.
> sd.c:343 sd_req_crc_validate(9) info: ignoring unreachable code.
> 
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>  hw/ide/microdrive.c |    3 ++-
>  hw/sd.c             |    2 ++
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
> index 64810f7..07c6f97 100644
> --- a/hw/ide/microdrive.c
> +++ b/hw/ide/microdrive.c
> @@ -207,7 +207,7 @@ static uint16_t md_common_read(void *opaque, uint32_t at)
>      case 0x0:	/* Even RD Data */
>      case 0x8:
>          return ide_data_readw(&s->bus, 0);
> -
> +#if 0
>          /* TODO: 8-bit accesses */
>          if (s->cycle)
>              ret = s->io >> 8;
> @@ -217,6 +217,7 @@ static uint16_t md_common_read(void *opaque, uint32_t at)
>          }
>          s->cycle = !s->cycle;
>          return ret;
> +#endif
>      case 0x9:	/* Odd RD Data */
>          return s->io >> 8;
>      case 0xd:	/* Error */
> diff --git a/hw/sd.c b/hw/sd.c
> index ec26407..62a7751 100644
> --- a/hw/sd.c
> +++ b/hw/sd.c
> @@ -340,7 +340,9 @@ static int sd_req_crc_validate(SDRequest *req)
>      buffer[3] = (req->arg >> 8) & 0xff;
>      buffer[4] = (req->arg >> 0) & 0xff;
>      return 0;
> +#if 0
>      return sd_crc7(buffer, 5) != req->crc;	/* TODO */
> +#endif

hw/sd.c:336:13: error: variable ‘buffer’ set but not used [-Werror=unused-but-set-variable]

I suggest we drop this dead code completely instead of using #if 0.

Stefan

Patch

diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
index 64810f7..07c6f97 100644
--- a/hw/ide/microdrive.c
+++ b/hw/ide/microdrive.c
@@ -207,7 +207,7 @@  static uint16_t md_common_read(void *opaque, uint32_t at)
     case 0x0:	/* Even RD Data */
     case 0x8:
         return ide_data_readw(&s->bus, 0);
-
+#if 0
         /* TODO: 8-bit accesses */
         if (s->cycle)
             ret = s->io >> 8;
@@ -217,6 +217,7 @@  static uint16_t md_common_read(void *opaque, uint32_t at)
         }
         s->cycle = !s->cycle;
         return ret;
+#endif
     case 0x9:	/* Odd RD Data */
         return s->io >> 8;
     case 0xd:	/* Error */
diff --git a/hw/sd.c b/hw/sd.c
index ec26407..62a7751 100644
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -340,7 +340,9 @@  static int sd_req_crc_validate(SDRequest *req)
     buffer[3] = (req->arg >> 8) & 0xff;
     buffer[4] = (req->arg >> 0) & 0xff;
     return 0;
+#if 0
     return sd_crc7(buffer, 5) != req->crc;	/* TODO */
+#endif
 }
 
 static void sd_response_r1_make(SDState *sd, uint8_t *response)