[v2] mtd: onenand_base: Avoid fall-through warnings
diff mbox series

Message ID 20190523191606.GA9838@embeddedor
State Accepted
Headers show
Series
  • [v2] mtd: onenand_base: Avoid fall-through warnings
Related show

Commit Message

Gustavo A. R. Silva May 23, 2019, 7:16 p.m. UTC
NOTICE THAT:

"...we don't know whether we need fallthroughs or breaks here and this
is just a change to avoid having new warnings when switching to
-Wimplicit-fallthrough but this change might be entirely wrong."[1]

See the original thread of discussion here:

https://lore.kernel.org/patchwork/patch/1036251/

So, in preparation to enabling -Wimplicit-fallthrough, this patch silences
the following warnings:

drivers/mtd/nand/onenand/onenand_base.c: In function ‘onenand_check_features’:
drivers/mtd/nand/onenand/onenand_base.c:3264:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
   if (ONENAND_IS_DDP(this))
      ^
drivers/mtd/nand/onenand/onenand_base.c:3284:2: note: here
  case ONENAND_DEVICE_DENSITY_2Gb:
  ^~~~
drivers/mtd/nand/onenand/onenand_base.c:3288:17: warning: this statement may fall through [-Wimplicit-fallthrough=]
   this->options |= ONENAND_HAS_UNLOCK_ALL;
drivers/mtd/nand/onenand/onenand_base.c:3290:2: note: here
  case ONENAND_DEVICE_DENSITY_1Gb:
  ^~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

Also, notice that this patch doesn't change any functionality. See the
most recent thread of discussion here:

https://lore.kernel.org/patchwork/patch/1077395/

This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.

[1] https://lore.kernel.org/lkml/20190509085318.34a9d4be@xps13/

Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Changes in v2:
 - Add breaks instead of fall-through markings without altering any
   functionality.
 - Update changelog text.

 drivers/mtd/nand/onenand/onenand_base.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Kees Cook May 23, 2019, 8:17 p.m. UTC | #1
On Thu, May 23, 2019 at 02:16:06PM -0500, Gustavo A. R. Silva wrote:
> NOTICE THAT:
> 
> "...we don't know whether we need fallthroughs or breaks here and this
> is just a change to avoid having new warnings when switching to
> -Wimplicit-fallthrough but this change might be entirely wrong."[1]
> 
> See the original thread of discussion here:
> 
> https://lore.kernel.org/patchwork/patch/1036251/
> 
> So, in preparation to enabling -Wimplicit-fallthrough, this patch silences
> the following warnings:
> 
> drivers/mtd/nand/onenand/onenand_base.c: In function ‘onenand_check_features’:
> drivers/mtd/nand/onenand/onenand_base.c:3264:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    if (ONENAND_IS_DDP(this))
>       ^
> drivers/mtd/nand/onenand/onenand_base.c:3284:2: note: here
>   case ONENAND_DEVICE_DENSITY_2Gb:
>   ^~~~
> drivers/mtd/nand/onenand/onenand_base.c:3288:17: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    this->options |= ONENAND_HAS_UNLOCK_ALL;
> drivers/mtd/nand/onenand/onenand_base.c:3290:2: note: here
>   case ONENAND_DEVICE_DENSITY_1Gb:
>   ^~~~
> 
> Warning level 3 was used: -Wimplicit-fallthrough=3
> 
> Also, notice that this patch doesn't change any functionality. See the
> most recent thread of discussion here:
> 
> https://lore.kernel.org/patchwork/patch/1077395/
> 
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
> 
> [1] https://lore.kernel.org/lkml/20190509085318.34a9d4be@xps13/
> 
> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
> Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

Thanks for updating this!

> ---
> Changes in v2:
>  - Add breaks instead of fall-through markings without altering any
>    functionality.
>  - Update changelog text.
> 
>  drivers/mtd/nand/onenand/onenand_base.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c
> index f41d76248550..fd0da5c347db 100644
> --- a/drivers/mtd/nand/onenand/onenand_base.c
> +++ b/drivers/mtd/nand/onenand/onenand_base.c
> @@ -3280,12 +3280,15 @@ static void onenand_check_features(struct mtd_info *mtd)
>  			if ((this->version_id & 0xf) == 0xe)
>  				this->options |= ONENAND_HAS_NOP_1;
>  		}
> +		this->options |= ONENAND_HAS_UNLOCK_ALL;
> +		break;
>  
>  	case ONENAND_DEVICE_DENSITY_2Gb:
>  		/* 2Gb DDP does not have 2 plane */
>  		if (!ONENAND_IS_DDP(this))
>  			this->options |= ONENAND_HAS_2PLANE;
>  		this->options |= ONENAND_HAS_UNLOCK_ALL;
> +		break;
>  
>  	case ONENAND_DEVICE_DENSITY_1Gb:
>  		/* A-Die has all block unlock */
> -- 
> 2.21.0
>

Patch
diff mbox series

diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c
index f41d76248550..fd0da5c347db 100644
--- a/drivers/mtd/nand/onenand/onenand_base.c
+++ b/drivers/mtd/nand/onenand/onenand_base.c
@@ -3280,12 +3280,15 @@  static void onenand_check_features(struct mtd_info *mtd)
 			if ((this->version_id & 0xf) == 0xe)
 				this->options |= ONENAND_HAS_NOP_1;
 		}
+		this->options |= ONENAND_HAS_UNLOCK_ALL;
+		break;
 
 	case ONENAND_DEVICE_DENSITY_2Gb:
 		/* 2Gb DDP does not have 2 plane */
 		if (!ONENAND_IS_DDP(this))
 			this->options |= ONENAND_HAS_2PLANE;
 		this->options |= ONENAND_HAS_UNLOCK_ALL;
+		break;
 
 	case ONENAND_DEVICE_DENSITY_1Gb:
 		/* A-Die has all block unlock */