Skip to contentSkip to conversation

hw/block/pflash_cfi02: Explicit switch fallthrough for ERASE commands

Qemu-devel Philippe Mathieu-Daudé 2 participants 2 messages Jul 11, 2019

lore
Share & tools
lore
#0 lore raw

Previous to commit ddb6f2254, the DQ2 bit was incorrectly set during PROGRAM command (0xA0). The commit reordered the switch cases to only set the DQ2 bit for the ERASE commands using a fallthrough, but did not explicit the fallthrough is intentional.

Mark the switch fallthrough with a comment interpretable by C preprocessors and static analysis tools.

Reported-by Coverity (CID 1403012)
---
 hw/block/pflash_cfi02.c | 1 +
 1 file changed, 1 insertion(+)
hw/block/pflash_cfi02.c +1 -0
index 83084b9d72..f68837a449 100644
@@ -367,6 +367,7 @@ static uint64_t pflash_read(void *opaque, hwaddr offset, unsigned int width)
     case 0x30: /* Sector Erase */
         /* Toggle bit 2 during erase, but not program. */
         toggle_dq2(pfl);
+        /* fall through */
     case 0xA0: /* Program */
         /* Toggle bit 6 */
         toggle_dq6(pfl);
Signature · 1 line
2.20.1
Reviewed-by
#1 lore raw
Quoted 20 lines · Philippe Mathieu-Daudé

Previous to commit ddb6f2254, the DQ2 bit was incorrectly set during PROGRAM command (0xA0). The commit reordered the switch cases to only set the DQ2 bit for the ERASE commands using a fallthrough, but did not explicit the fallthrough is intentional.

Mark the switch fallthrough with a comment interpretable by C preprocessors and static analysis tools.

Reported-by Coverity (CID 1403012)
---
 hw/block/pflash_cfi02.c | 1 +
 1 file changed, 1 insertion(+)
hw/block/pflash_cfi02.c +0 -0
index 83084b9d72..f68837a449 100644

hw/block/pflash_cfi02.c static uint64_t pflash_read(void *opaque, hwaddr offset, unsigned int width)

Quoted 8 lines
hw/block/pflash_cfi02.c +1 -1
@@ -367,6 +367,7 @@ static uint64_t pflash_read(void *opaque, hwaddr offset, unsigned int width)
     case 0x30: /* Sector Erase */
         /* Toggle bit 2 during erase, but not program. */
         toggle_dq2(pfl);
+        /* fall through */
     case 0xA0: /* Program */
         /* Toggle bit 6 */
         toggle_dq6(pfl);
--

thanks
-- PMM