[Qemu-devel] [PATCH-for-4.1] hw/block/pflash_cfi02: Explicit switch fallthrough for ERASE commands

Philippe Mathieu-Daudé posted 1 patch 13 weeks ago
Test asan passed
Test docker-mingw@fedora passed
Test docker-clang@ubuntu passed
Test s390x passed
Test FreeBSD passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190711130759.27720-1-philmd@redhat.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, Max Reitz <mreitz@redhat.com>
hw/block/pflash_cfi02.c | 1 +
1 file changed, 1 insertion(+)

[Qemu-devel] [PATCH-for-4.1] hw/block/pflash_cfi02: Explicit switch fallthrough for ERASE commands

Posted by Philippe Mathieu-Daudé 13 weeks ago
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)
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/block/pflash_cfi02.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
index 83084b9d72..f68837a449 100644
--- a/hw/block/pflash_cfi02.c
+++ b/hw/block/pflash_cfi02.c
@@ -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);
-- 
2.20.1


Re: [Qemu-devel] [PATCH-for-4.1] hw/block/pflash_cfi02: Explicit switch fallthrough for ERASE commands

Posted by Peter Maydell 13 weeks ago
On Thu, 11 Jul 2019 at 14:08, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> 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)
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/block/pflash_cfi02.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
> index 83084b9d72..f68837a449 100644
> --- a/hw/block/pflash_cfi02.c
> +++ b/hw/block/pflash_cfi02.c
> @@ -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);
> --

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM