Skip to contentSkip to conversation

pflash_cfi01: Fix warning caused by unreachable code

PATCH Applied Stefan Weil 2 participants 3 messages Sep 1, 2012 – Sep 22, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pflash_cfi01: Fix warning caused by unreachable code

Report from smatch:
hw/pflash_cfi01.c:431 pflash_write(180) info: ignoring unreachable code.

Instead of removing the return statement after the switch statement, the patch replaces the return statements in the switch statement by break statements. Other switch statements in the same code do it also like that.

---
 hw/pflash_cfi01.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/pflash_cfi01.c +4 -4
index d1c7423..56ed33f 100644
@@ -320,7 +320,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset,
         }
         pfl->wcycle++;
         pfl->cmd = cmd;
-        return;
+        break;
     case 1:
         switch (pfl->cmd) {
         case 0x10: /* Single Byte Program */
@@ -375,7 +375,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset,
         default:
             goto error_flash;
         }
-        return;
+        break;
     case 2:
         switch (pfl->cmd) {
         case 0xe8: /* Block write */
@@ -406,7 +406,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset,
         default:
             goto error_flash;
         }
-        return;
+        break;
     case 3: /* Confirm mode */
         switch (pfl->cmd) {
         case 0xe8: /* Block write */
@@ -422,7 +422,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset,
         default:
             goto error_flash;
         }
-        return;
+        break;
     default:
         /* Should never happen */
         DPRINTF("%s: invalid write state\n",  __func__);
Signature · 1 line
1.7.10
#1 lore raw

Am 01.09.2012 13:00, schrieb Stefan Weil:

Quoted 46 lines

Report from smatch:
hw/pflash_cfi01.c:431 pflash_write(180) info: ignoring unreachable code.

Instead of removing the return statement after the switch statement, the patch replaces the return statements in the switch statement by break statements. Other switch statements in the same code do it also like that.

---
  hw/pflash_cfi01.c |    8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
hw/pflash_cfi01.c +3 -3
index d1c7423..56ed33f 100644
@@ -320,7 +320,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset,
          }
          pfl->wcycle++;
          pfl->cmd = cmd;
-        return;
+        break;
      case 1:
          switch (pfl->cmd) {
          case 0x10: /* Single Byte Program */
@@ -375,7 +375,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset,
          default:
              goto error_flash;
          }
-        return;
+        break;
      case 2:
          switch (pfl->cmd) {
          case 0xe8: /* Block write */
@@ -406,7 +406,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset,
          default:
              goto error_flash;
          }
-        return;
+        break;
      case 3: /* Confirm mode */
          switch (pfl->cmd) {
          case 0xe8: /* Block write */

hw/pflash_cfi01.c static void pflash_write(pflash_t *pfl, target_phys_addr_t offset, · line 428

Quoted 8 lines
hw/pflash_cfi01.c +1 -1
@@ -422,7 +422,7 @@ static void pflash_write(pflash_t *pfl, target_phys_addr_t offset,
          default:
              goto error_flash;
          }
-        return;
+        break;
      default:
          /* Should never happen */
          DPRINTF("%s: invalid write state\n",  __func__);

Ping?

#2 lore raw
In reply to Stefan Weil
Quoted 8 lines · Stefan Weil

Report from smatch:
hw/pflash_cfi01.c:431 pflash_write(180) info: ignoring unreachable code.

Instead of removing the return statement after the switch statement, the patch replaces the return statements in the switch statement by break statements. Other switch statements in the same code do it also like that.

Quoted 4 lines
---
 hw/pflash_cfi01.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan