Linux-ARM-Kernel Archive on lore.kernel.org
 help / Atom feed
* [PATCH] clk: samsung: s3c2443: Mark expected switch fall-through
@ 2019-02-11 18:15 ` Gustavo A. R. Silva
  2019-02-12  0:37   ` Chanwoo Choi
  2019-02-12  7:40   ` Krzysztof Kozlowski
  0 siblings, 2 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2019-02-11 18:15 UTC (permalink / raw)
  To: Kukjin Kim, Krzysztof Kozlowski, Sylwester Nawrocki, Tomasz Figa,
	Chanwoo Choi, Michael Turquette, Stephen Boyd
  Cc: linux-samsung-soc, Kees Cook, Gustavo A. R. Silva, linux-kernel,
	linux-clk, linux-arm-kernel

In preparation to enabling -Wimplicit-fallthrough, mark switch
cases where we are expecting to fall through.

This patch fixes the following warnings:

drivers/clk/samsung/clk-s3c2443.c: In function ‘s3c2443_common_clk_init’:
drivers/clk/samsung/clk-s3c2443.c:390:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
   samsung_clk_register_alias(ctx, s3c2450_aliases,
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     ARRAY_SIZE(s3c2450_aliases));
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clk/samsung/clk-s3c2443.c:393:2: note: here
  case S3C2416:
  ^~~~

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

Notice that, in this particular case,  the code comment is modified
in accordance with what GCC is expecting to find.

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

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/clk/samsung/clk-s3c2443.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/samsung/clk-s3c2443.c b/drivers/clk/samsung/clk-s3c2443.c
index 884067e4f1a1..f38f0e24e3b6 100644
--- a/drivers/clk/samsung/clk-s3c2443.c
+++ b/drivers/clk/samsung/clk-s3c2443.c
@@ -389,7 +389,7 @@ void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
 				ARRAY_SIZE(s3c2450_gates));
 		samsung_clk_register_alias(ctx, s3c2450_aliases,
 				ARRAY_SIZE(s3c2450_aliases));
-		/* fall through, as s3c2450 extends the s3c2416 clocks */
+		/* fall through - as s3c2450 extends the s3c2416 clocks */
 	case S3C2416:
 		samsung_clk_register_div(ctx, s3c2416_dividers,
 				ARRAY_SIZE(s3c2416_dividers));
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: samsung: s3c2443: Mark expected switch fall-through
  2019-02-11 18:15 ` [PATCH] clk: samsung: s3c2443: Mark expected switch fall-through Gustavo A. R. Silva
@ 2019-02-12  0:37   ` Chanwoo Choi
  2019-02-12  7:40   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 5+ messages in thread
From: Chanwoo Choi @ 2019-02-12  0:37 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Kukjin Kim, Krzysztof Kozlowski,
	Sylwester Nawrocki, Tomasz Figa, Michael Turquette, Stephen Boyd
  Cc: Kees Cook, linux-samsung-soc, linux-clk, linux-arm-kernel, linux-kernel

Hi Gustavo,

On 19. 2. 12. 오전 3:15, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch
> cases where we are expecting to fall through.
> 
> This patch fixes the following warnings:
> 
> drivers/clk/samsung/clk-s3c2443.c: In function ‘s3c2443_common_clk_init’:
> drivers/clk/samsung/clk-s3c2443.c:390:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    samsung_clk_register_alias(ctx, s3c2450_aliases,
>    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>      ARRAY_SIZE(s3c2450_aliases));
>      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/clk/samsung/clk-s3c2443.c:393:2: note: here
>   case S3C2416:
>   ^~~~
> 
> Warning level 3 was used: -Wimplicit-fallthrough=3
> 
> Notice that, in this particular case,  the code comment is modified
> in accordance with what GCC is expecting to find.
> 
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.

Except for level 5 of -Wimplicit-fallthrough,
level 4 is more strict to show the warnings.
Why don't you support level 4 for -Wimplicit-fallthrough?
I think that you want to fix for -Wimplicit-fallthrough warning,
you better to support level 4. What do you think?


> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>  drivers/clk/samsung/clk-s3c2443.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/samsung/clk-s3c2443.c b/drivers/clk/samsung/clk-s3c2443.c
> index 884067e4f1a1..f38f0e24e3b6 100644
> --- a/drivers/clk/samsung/clk-s3c2443.c
> +++ b/drivers/clk/samsung/clk-s3c2443.c
> @@ -389,7 +389,7 @@ void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
>  				ARRAY_SIZE(s3c2450_gates));
>  		samsung_clk_register_alias(ctx, s3c2450_aliases,
>  				ARRAY_SIZE(s3c2450_aliases));
> -		/* fall through, as s3c2450 extends the s3c2416 clocks */
> +		/* fall through - as s3c2450 extends the s3c2416 clocks */
>  	case S3C2416:
>  		samsung_clk_register_div(ctx, s3c2416_dividers,
>  				ARRAY_SIZE(s3c2416_dividers));
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: samsung: s3c2443: Mark expected switch fall-through
  2019-02-11 18:15 ` [PATCH] clk: samsung: s3c2443: Mark expected switch fall-through Gustavo A. R. Silva
  2019-02-12  0:37   ` Chanwoo Choi
@ 2019-02-12  7:40   ` Krzysztof Kozlowski
  2019-02-12 18:57     ` Kees Cook
  1 sibling, 1 reply; 5+ messages in thread
From: Krzysztof Kozlowski @ 2019-02-12  7:40 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: linux-samsung-soc, Kees Cook, Stephen Boyd, Michael Turquette,
	Tomasz Figa, linux-kernel, Chanwoo Choi, Kukjin Kim,
	Sylwester Nawrocki, linux-clk, linux-arm-kernel

On Mon, 11 Feb 2019 at 19:40, Gustavo A. R. Silva
<gustavo@embeddedor.com> wrote:
>
> In preparation to enabling -Wimplicit-fallthrough, mark switch
> cases where we are expecting to fall through.
>
> This patch fixes the following warnings:
>
> drivers/clk/samsung/clk-s3c2443.c: In function ‘s3c2443_common_clk_init’:
> drivers/clk/samsung/clk-s3c2443.c:390:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
>    samsung_clk_register_alias(ctx, s3c2450_aliases,
>    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>      ARRAY_SIZE(s3c2450_aliases));
>      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/clk/samsung/clk-s3c2443.c:393:2: note: here
>   case S3C2416:
>   ^~~~
>
> Warning level 3 was used: -Wimplicit-fallthrough=3
>
> Notice that, in this particular case,  the code comment is modified
> in accordance with what GCC is expecting to find.
>
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.

I saw this in multiple places already and I think fix is wrong. The
point is that the code is correct - the fall through is marked
properly.

It is just the GCC which has to be fixed not the code. You want to
adjust the code for specific version of GCC and what if GCC changes
its warning? For example GCC might require "fall through: "... or any
other syntax. Another point - what about clang's syntax?

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: samsung: s3c2443: Mark expected switch fall-through
  2019-02-12  7:40   ` Krzysztof Kozlowski
@ 2019-02-12 18:57     ` Kees Cook
  2019-02-16  0:34       ` Stephen Boyd
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2019-02-12 18:57 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: linux-samsung-soc, Gustavo A. R. Silva, Stephen Boyd,
	Michael Turquette, Tomasz Figa, LKML, Chanwoo Choi, Kukjin Kim,
	Sylwester Nawrocki, linux-clk, linux-arm-kernel

On Mon, Feb 11, 2019 at 11:41 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Mon, 11 Feb 2019 at 19:40, Gustavo A. R. Silva
> <gustavo@embeddedor.com> wrote:
> >
> > In preparation to enabling -Wimplicit-fallthrough, mark switch
> > cases where we are expecting to fall through.
> >
> > This patch fixes the following warnings:
> >
> > drivers/clk/samsung/clk-s3c2443.c: In function ‘s3c2443_common_clk_init’:
> > drivers/clk/samsung/clk-s3c2443.c:390:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
> >    samsung_clk_register_alias(ctx, s3c2450_aliases,
> >    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >      ARRAY_SIZE(s3c2450_aliases));
> >      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > drivers/clk/samsung/clk-s3c2443.c:393:2: note: here
> >   case S3C2416:
> >   ^~~~
> >
> > Warning level 3 was used: -Wimplicit-fallthrough=3
> >
> > Notice that, in this particular case,  the code comment is modified
> > in accordance with what GCC is expecting to find.
> >
> > This patch is part of the ongoing efforts to enable
> > -Wimplicit-fallthrough.
>
> I saw this in multiple places already and I think fix is wrong. The
> point is that the code is correct - the fall through is marked
> properly.
>
> It is just the GCC which has to be fixed not the code. You want to
> adjust the code for specific version of GCC and what if GCC changes
> its warning? For example GCC might require "fall through: "... or any
> other syntax. Another point - what about clang's syntax?

-Wimplicit-fallthrough=3 is stricter and maps to -Wextra, hence its
choice. GCC's levels were chosen based on the existing linters, static
analyzers, etc. The patterns are unlikely to change (see the gcc
man-page).

Clang doesn't recognize anything in C mode (hopefully this will be
fixed in the future[1]).

As long as one of the compilers is able to check this, we'll avoid the
bugs associated with this mis-pattern. Gustavo's efforts here have
found kind of a lot of bugs, so I think it's worth a little churn to
add these (and make minor adjustments to existing comments).

[1] https://bugs.llvm.org/show_bug.cgi?id=37135

-- 
Kees Cook

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] clk: samsung: s3c2443: Mark expected switch fall-through
  2019-02-12 18:57     ` Kees Cook
@ 2019-02-16  0:34       ` Stephen Boyd
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Boyd @ 2019-02-16  0:34 UTC (permalink / raw)
  To: Kees Cook, Krzysztof Kozlowski
  Cc: linux-samsung-soc, Gustavo A. R. Silva, Michael Turquette,
	Tomasz Figa, LKML, Chanwoo Choi, Kukjin Kim, Sylwester Nawrocki,
	linux-clk, linux-arm-kernel

Quoting Kees Cook (2019-02-12 10:57:05)
> On Mon, Feb 11, 2019 at 11:41 PM Krzysztof Kozlowski <krzk@kernel.org> wrote:
> >
> > It is just the GCC which has to be fixed not the code. You want to
> > adjust the code for specific version of GCC and what if GCC changes
> > its warning? For example GCC might require "fall through: "... or any
> > other syntax. Another point - what about clang's syntax?
> 
> -Wimplicit-fallthrough=3 is stricter and maps to -Wextra, hence its
> choice. GCC's levels were chosen based on the existing linters, static
> analyzers, etc. The patterns are unlikely to change (see the gcc
> man-page).
> 
> Clang doesn't recognize anything in C mode (hopefully this will be
> fixed in the future[1]).
> 
> As long as one of the compilers is able to check this, we'll avoid the
> bugs associated with this mis-pattern. Gustavo's efforts here have
> found kind of a lot of bugs, so I think it's worth a little churn to
> add these (and make minor adjustments to existing comments).

Just curious, what compilation phase does this check run in? Could we
gain a macro like FALLTHRU or even lowercase 'fallthru' that expanded to
whatever the compiler wants to see and then there would only be "one
way" to do this?  It would alleviate the above concerns, but maybe I'm
rehashing something that's already been proposed and rejected.

Of course, I'm happy to merge any of these patches that tweak things so
no worries either way.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20190211181544epcas4p1d899221776a647a5bdf21372304bf0d7@epcas4p1.samsung.com>
2019-02-11 18:15 ` [PATCH] clk: samsung: s3c2443: Mark expected switch fall-through Gustavo A. R. Silva
2019-02-12  0:37   ` Chanwoo Choi
2019-02-12  7:40   ` Krzysztof Kozlowski
2019-02-12 18:57     ` Kees Cook
2019-02-16  0:34       ` Stephen Boyd

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org infradead-linux-arm-kernel@archiver.kernel.org
	public-inbox-index linux-arm-kernel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox