Fix fall-through warnings for Clang
Subsystems (140)
Quoted 26 lines · Nick Desaulniers
(minus all of these lists, except LKML, CBL, and ACPI)
Quoted 22 lines · Jakub Kicinski
Quoted 3 lines · On Mon, 23 Nov 2020 17:32:51 -0800 Nick Desaulniers wrote:
Quoted 2 lines · Kees Cook
Quoted 1 line · Jakub Kicinski
If none of the 140 patches here fix a real bug, and there is no
change
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
to machine code then it sounds to me like a W=2 kind of a warning.
FWIW, this series has found at least one bug so far:
https://lore.kernel.org/lkml/CAFCwf11izHF=g1mGry1fE5kvFFFrxzhPSM6qKAO8gxSp=Kr_CQ@mail.gmail.com/
Quoted 11 lines
So looks like the bulk of these are:
switch (x) {
case 0:
++x;
default:
break;
}I have a patch that fixes those up for clang:
https://reviews.llvm.org/D91895
Pity. It's a good warning. gcc not warning is a mistake in my view.
Quoted 11 lines · Joe Perches
Quoted 3 lines · Finn Thain
it's not for me to prove that such patches don't affect code generation. That's for the patch author and (unfortunately) for reviewers.
Ideally, that proof would be provided by the compilation system itself and not patch authors nor reviewers nor maintainers.
Unfortunately gcc does not guarantee repeatability or deterministic output. To my knowledge, neither does clang.
Yes, I've said the same thing myself. But having attempted it, I now think this is a hard problem. YMMV.
https://lore.kernel.org/linux-scsi/[email protected]/
https://lore.kernel.org/linux-scsi/[email protected]/
Re: [PATCH 126/141] slimbus: messaging: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 7 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
---
Applied thanks,
srini
Quoted 16 lines
drivers/slimbus/messaging.c | 1 + 1 file changed, 1 insertion(+)drivers/slimbus/messaging.c +1
-0@@ -258,6 +258,7 @@ int slim_xfer_msg(struct slim_device *sbdev, struct slim_val_inf *msg,case SLIM_MSG_MC_REQUEST_CLEAR_INFORMATION :case SLIM_MSG_MC_CLEAR_INFORMATION : txn->rl += msg->num_bytes; +break ;default :break ; }
David Howells
maintainerRe: [PATCH 001/141] afs: Fix fall-through warnings for Clang
In reply to Joe PerchesQuoted 8 lines · Joe Perches
Quoted 2 lines
My preference would be to fall through. The case number is the state machine state, as indexed by
call->unmarshall.Then ideally the state machine states should be enums and not numbers and the compiler should use a default block for unhandled states right?
Is code like call->marshall++ a common style for kernel state machines? Perhaps not.
How the value is interpreted is unique to each delivery function, of which there are a number, since it counts out the separate parts of the xdr encoding for that particular RPC request or reply block.
Maybe "state machine" isn't the right term.
David
Re: [PATCH 098/141] mmc: sdhci-of-arasan: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 7 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of letting the code fall through to the next case.
Applied for next, thanks!
Kind regards
Uffe
Quoted 43 lines
--- drivers/mmc/host/sdhci-of-arasan.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mmc/host/sdhci-of-arasan.c +4
-1@@ -627,6 +627,7 @@ static int sdhci_zynqmp_sdcardclk_set_phase(struct clk_hw *hw, int degrees)case MMC_TIMING_MMC_HS200 :/* For 200MHz clock, 8 Taps are available */ tap_max =8 ; +break ;default :break ; }@@ -695,6 +696,7 @@ static int sdhci_zynqmp_sampleclk_set_phase(struct clk_hw *hw, int degrees)case MMC_TIMING_MMC_HS200 :/* For 200MHz clock, 30 Taps are available */ tap_max =30 ; +break ;default :break ; }@@ -760,6 +762,7 @@ static int sdhci_versal_sdcardclk_set_phase(struct clk_hw *hw, int degrees)case MMC_TIMING_MMC_HS200 :/* For 200MHz clock, 8 Taps are available */ tap_max =8 ; +break ;default :break ; }@@ -831,6 +834,7 @@ static int sdhci_versal_sampleclk_set_phase(struct clk_hw *hw, int degrees)case MMC_TIMING_MMC_HS200 :/* For 200MHz clock, 30 Taps are available */ tap_max =30 ; +break ;default :break ; } --2.27.0
Re: [PATCH 052/141] security: keys: Fix fall-through warnings for Clang
In reply to Jarkko SakkinenQuoted 22 lines · Jarkko Sakkinen
Quoted 21 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- security/keys/process_keys.c | 1 + 1 file changed, 1 insertion(+)security/keys/process_keys.c +1
-0@@ -783,6 +783,7 @@ key_ref_t lookup_user_key(key_serial_t id, unsigned long lflags,if (need_perm !=KEY_AUTHTOKEN_OVERRIDE && need_perm !=KEY_DEFER_PERM_CHECK ) goto invalid_key; +break ;case 0 :break ;
Quoted 8 lines
Quoted 5 lines
security/keys/process_keys.c +0
-0}Signature · 1 line
2.27.0Reviewed-by Jarkko Sakkinen <[email protected]>
Thank you, Jarkko.
--
Gustavo
Re: [PATCH 053/141] selinux: Fix fall-through warnings for Clang
In reply to Paul MooreQuoted 7 lines · Paul Moore
Quoted 5 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
Quoted 7 lines
Quoted 5 lines
--- security/selinux/hooks.c | 1 + 1 file changed, 1 insertion(+)Merged into selinux/next, thanks.
Thanks, Paul.
--
Gustavo
Re: [PATCH 084/141] drm/via: Fix fall-through warnings for Clang
In reply to Sam RavnborgQuoted 9 lines · Sam Ravnborg
Quoted 6 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
Thanks, also applied to drm-misc-next.
Thank you, Sam.
--
Gustavo
Re: [PATCH 086/141] hwmon: (corsair-cpro) Fix fall-through warnings for Clang
In reply to Guenter RoeckQuoted 9 lines · Guenter Roeck
Quoted 6 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
Acked-by Guenter Roeck <[email protected]>
Thanks, Guenter.
--
Gustavo
Re: [PATCH 098/141] mmc: sdhci-of-arasan: Fix fall-through warnings for Clang
In reply to Ulf HanssonQuoted 10 lines · Ulf Hansson
Quoted 7 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of letting the code fall through to the next case.
Applied for next, thanks!
Thank you, Uffe.
--
Gustavo
Re: [PATCH 108/141] netfilter: ipt_REJECT: Fix fall-through warnings for Clang
In reply to Florian WestphalQuoted 6 lines · Florian Westphal
Quoted 3 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
Acked-by Florian Westphal <[email protected]>
Thanks, Florian.
--
Gustavo
Re: [PATCH 126/141] slimbus: messaging: Fix fall-through warnings for Clang
In reply to Srinivas KandagatlaQuoted 7 lines · Srinivas Kandagatla
Quoted 4 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
Quoted 6 lines
Quoted 3 lines
---
Applied thanks,
Thank you, Srini.
--
Gustavo
Re: [PATCH 131/141] tpm: Fix fall-through warnings for Clang
In reply to Jarkko SakkinenQuoted 31 lines · Jarkko Sakkinen
Quoted 30 lines · Jarkko Sakkinen
Quoted 26 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- drivers/char/tpm/eventlog/tpm1.c | 1 + 1 file changed, 1 insertion(+)drivers/char/tpm/eventlog/tpm1.c +1
-0@@ -210,6 +210,7 @@ static int get_event_name(char *dest, struct tcpa_event *event,default :break ; } +break ;default :break ; }Signature · 1 line
2.27.0Reviewed-by Jarkko Sakkinen <[email protected]>
Quoted 1 line
Quoted 1 line
Who is picking these patches?
I can take it in my tree for 5.11 if people are OK with that. :)
Quoted 6 lines
Quoted 2 lines
/Jarkko
I mean
Reviewed-by Jarkko Sakkinen <[email protected]>
Thanks, Jarkko.
--
Gustavo
Re: [PATCH 134/141] video: fbdev: lxfb_ops: Fix fall-through warnings for Clang
In reply to Sam RavnborgHi Sam,
Quoted 9 lines · Sam Ravnborg
Hi Gustavo,
Quoted 6 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
Quoted 6 lines
Thanks, applied this and the following patch to drm-misc-next. Looks forward to have this warning enabled.
One can only wonder how many hours will be saved by lettting the compiler tell you a break is missing. This is the kind of bugs you can stare you blind at.
Absolutely. We'll never know how many bugs this will catch in the future decades of kernel development, before the code is even committed/submitted. :)
Thanks!
--
Gustavo
Re: [PATCH 141/141] Input: libps2 - Fix fall-through warnings for Clang
In reply to Dmitry TorokhovQuoted 5 lines · Dmitry Torokhov
Quoted 4 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by replacing a /* Fall through */ comment with the new pseudo-keyword macro fallthrough.
Quoted 7 lines
Quoted 5 lines
Notice that Clang doesn't recognize /* Fall through */ comments as implicit fall-through markings.
Applied, thank you.
Thank you, Dmitry.
--
Gustavo
Quoted 8 lines · Jason Gunthorpe
Quoted 4 lines · Gustavo A. R. Silva
IB/hfi1: Fix fall-through warnings for Clang
IB/mlx4: Fix fall-through warnings for Clang
IB/qedr: Fix fall-through warnings for Clang
RDMA/mlx5: Fix fall-through warnings for ClangI picked these four to the rdma tree, thanks
Awesome. :)
Thank you, Jason.
--
Gustavo
Quoted 10 lines · Mark Brown
Quoted 8 lines · Gustavo A. R. Silva
This series aims to fix almost all remaining fall-through warnings in order to enable -Wimplicit-fallthrough for Clang.
In preparation to enable -Wimplicit-fallthrough for Clang, explicitly add multiple break/goto/return/fallthrough statements instead of just letting the code fall through to the next case.
[...]
Quoted 8 lines
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
Thanks!
[1/1] regulator: as3722: Fix fall-through warnings for Clang
commit: b52b417ccac4fae5b1f2ec4f1d46eb91e4493dc5
Thank you, Mark.
--
Gustavo
Re: [PATCH 117/141] rtl8xxxu: Fix fall-through warnings for Clang
In reply to Jes SorensenQuoted 15 lines · Jes Sorensen
Quoted 5 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by replacing /* fall through */ comments with the new pseudo-keyword macro fallthrough; instead of letting the code fall through to the next case.
Quoted 8 lines
Notice that Clang doesn't recognize /* fall through */ comments as implicit fall-through markings.
--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Quoted 5 lines
While I wasn't CC'ed on the cover-letter I see Jakub also raised issues about this unnecessary patch noise.
Quite frankly, this seems to be patch churn for the sake of patch churn. If clang is broken, fix clang instead.
Just notice that the idea behind this and the following patch is exactly the same:
I could resend this same patch with a different changelog text, but I don't think such a thing is necessary. However, if people prefer that approach, just let me know and I can do it.
Thanks
--
Gustavo
Quoted 38 lines
Quoted 37 lines
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +4
-4@@ -1145,7 +1145,7 @@ void rtl8xxxu_gen1_config_channel(struct ieee80211_hw *hw)switch (hw->conf.chandef.width) {case NL80211_CHAN_WIDTH_20_NOHT : ht = false; -/* fall through */ + fallthrough;case NL80211_CHAN_WIDTH_20 : opmode |=BW_OPMODE_20MHZ ;rtl8xxxu_write8 (priv,REG_BW_OPMODE , opmode);@@ -1272,7 +1272,7 @@ void rtl8xxxu_gen2_config_channel(struct ieee80211_hw *hw)switch (hw->conf.chandef.width) {case NL80211_CHAN_WIDTH_20_NOHT : ht = false; -/* fall through */ + fallthrough;case NL80211_CHAN_WIDTH_20 : rf_mode_bw |=WMAC_TRXPTCL_CTL_BW_20 ; subchannel =0 ;@@ -1741,11 +1741,11 @@ static int rtl8xxxu_identify_chip(struct rtl8xxxu_priv *priv)case 3 : priv->ep_tx_low_queue =1 ; priv->ep_tx_count++; -/* fall through */ + fallthrough;case 2 : priv->ep_tx_normal_queue =1 ; priv->ep_tx_count++; -/* fall through */ + fallthrough;case 1 : priv->ep_tx_high_queue =1 ; priv->ep_tx_count++;
Quoted 12 lines · Nick Desaulniers
Quoted 7 lines · Kees Cook
Quoted 2 lines · Jakub Kicinski
If none of the 140 patches here fix a real bug, and there is no change to machine code then it sounds to me like a W=2 kind of a warning.
FWIW, this series has found at least one bug so far:
https://lore.kernel.org/lkml/CAFCwf11izHF=g1mGry1fE5kvFFFrxzhPSM6qKAO8gxSp=Kr_CQ@mail.gmail.com/So looks like the bulk of these are:
switch (x) {
case 0:
Quoted 7 lines
++x; default: break; }I have a patch that fixes those up for clang:
https://reviews.llvm.org/D91895
I still think this isn't right -- it's a case statement that runs off the end without an explicit flow control determination. I think Clang is right to warn for these, and GCC should also warn.
Signature · 1 line
Kees Cook
Quoted 5 lines · James Bottomley
Really, no ... something which produces no improvement has no value at all ... we really shouldn't be wasting maintainer time with it because it has a cost to merge. I'm not sure we understand where the balance lies in value vs cost to merge but I am confident in the zero value case.
What? We can't measure how many future bugs aren't introduced because the kernel requires explicit case flow-control statements for all new code.
We already enable -Wimplicit-fallthrough globally, so that's not the discussion. The issue is that Clang is (correctly) even more strict than GCC for this, so these are the remaining ones to fix for full Clang coverage too.
People have spent more time debating this already than it would have taken to apply the patches. :)
This is about robustness and language wrangling. It's a big code-base, and this is the price of our managing technical debt for permanent robustness improvements. (The numbers I ran from Gustavo's earlier patches were that about 10% of the places adjusted were identified as legitimate bugs being fixed. This final series may be lower, but there are still bugs being found from it -- we need to finish this and shut the door on it for good.)
Signature · 1 line
Kees Cook
Quoted 11 lines · Kees Cook
Quoted 5 lines · James Bottomley
Really, no ... something which produces no improvement has no value at all ... we really shouldn't be wasting maintainer time with it because it has a cost to merge. I'm not sure we understand where the balance lies in value vs cost to merge but I am confident in the zero value case.
What? We can't measure how many future bugs aren't introduced because the kernel requires explicit case flow-control statements for all new code.
These statements are not "missing" unless you presume that code written before the latest de facto language spec was written should somehow be held to that spec.
If the 'fallthrough' statement is not part of the latest draft spec then we should ask why not before we embrace it. Being that the kernel still prefers -std=gnu89 you might want to consider what has prevented -std=gnu99 or -std=gnu2x etc.
Quoted 5 lines
We already enable -Wimplicit-fallthrough globally, so that's not the discussion. The issue is that Clang is (correctly) even more strict than GCC for this, so these are the remaining ones to fix for full Clang coverage too.
Seems to me you should be patching the compiler.
When you have consensus among the language lawyers you'll have more credibility with those being subjected to enforcement.
Quoted 4 lines · Finn Thain
These statements are not "missing" unless you presume that code written before the latest de facto language spec was written should somehow be held to that spec.
There is no "language spec" the kernel adheres to. Even if it did, kernel code is not frozen. If an improvement is found, it should be applied.
Quoted 4 lines
If the 'fallthrough' statement is not part of the latest draft spec then we should ask why not before we embrace it. Being that the kernel still prefers -std=gnu89 you might want to consider what has prevented -std=gnu99 or -std=gnu2x etc.
The C standard has nothing to do with this. We use compiler extensions of several kinds, for many years. Even discounting those extensions, the kernel is not even conforming to C due to e.g. strict aliasing. I am not sure what you are trying to argue here.
But, since you insist: yes, the fallthrough attribute is in the current C2x draft.
Cheers,
Miguel
Quoted 2 lines · Finn Thain
What I meant was that you've used pessimism as if it was fact.
"future mistakes that it might prevent" is neither pessimism nor states a fact.
Quoted 3 lines
For example, "There is no way to guess what the effect would be if the compiler trained programmers to add a knee-jerk 'break' statement to avoid a warning".
It is only knee-jerk if you think you are infallible.
Quoted 2 lines
Moreover, what I meant was that preventing programmer mistakes is a problem to be solved by development tools
This warning comes from a development tool -- the compiler.
Quoted 3 lines
The idea that retro-fitting new
language constructs onto mature code is somehow necessary to "prevent future mistakes" is entirely questionable.
The kernel is not a frozen codebase.
Further, "mature code vs. risk of change" arguments don't apply here because the semantics of the program and binary output isn't changing.
Quoted 3 lines
Sure. And if you put -Wimplicit-fallthrough into the
Makefileand if that leads to well-intentioned patches that cause regressions, it is partly on you.
Again: adding a fallthrough does not change the program semantics. If you are a maintainer and want to cross-check, compare the codegen.
Quoted 2 lines
Have you ever considered the overall cost of the countless -Wpresume-incompetence flags?
Yeah: negative. On the other hand, the overall cost of the countless -fI-am-infallible flags is very noticeable.
Quoted 11 lines
Perhaps you pay the power bill for a build farm that produces logs that no-one reads? Perhaps you've run git bisect, knowing that the compiler messages are not interesting? Or compiled software in using a language that generates impenetrable messages? If so, here's a tip:
# grep CFLAGS /etc/portage/make.conf CFLAGS="... -Wno-all -Wno-extra ..." CXXFLAGS="${CFLAGS}"Now allow me some pessimism: the hardware upgrades, gigawatt hours and wait time attributable to obligatory static analyses are a net loss.
If you really believe compiler warnings and static analysis are useless and costly, I think there is not much point in continuing the discussion.
Quoted 2 lines
No, it's not for me to prove that such patches don't affect code generation. That's for the patch author and (unfortunately) for reviewers.
I was not asking you to prove it. I am stating that proving it is very easy.
Cheers,
Miguel
Quoted 6 lines · Miguel Ojeda
The C standard has nothing to do with this. We use compiler extensions of several kinds, for many years. Even discounting those extensions, the kernel is not even conforming to C due to e.g. strict aliasing. I am not sure what you are trying to argue here.
I'm saying that supporting the official language spec makes more sense than attempting to support a multitude of divergent interpretations of the spec (i.e. gcc, clang, coverity etc.)
I'm also saying that the reason why we use -std=gnu89 is that existing code was written in that language, not in ad hoc languages comprised of collections of extensions that change with every release.
Quoted 3 lines
But, since you insist: yes, the
fallthroughattribute is in the current C2x draft.
Thank you for checking. I found a free version that's only 6 weeks old:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2583.pdf
It will be interesting to see whether 6.7.11.5 changes once the various implementations reach agreement.
Quoted 3 lines · James Bottomley
So you think a one line patch should take one minute to produce ... I really don't think that's grounded in reality.
No, I have not said that. Please don't put words in my mouth (again).
I have said *authoring* lines of *this* kind takes a minute per line.
Specifically: lines fixing the fallthrough warning mechanically and repeatedly where the compiler tells you to, and doing so full-time for a month.
For instance, take the following one from Gustavo. Are you really saying it takes 12 minutes (your number) to write that break;?
drivers/gpu/drm/via/via_irq.c +0 -0
@@ -364,6 +364,7 @@ int via_wait_irq(struct drm_device *dev, void
*data, struct drm_file *file_priv)
irqwait->request.sequence +=
atomic_read(&cur_irq->irq_received);
irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
+ break;
case VIA_IRQ_ABSOLUTE:
break;
default:Quoted 3 lines
I suppose a one line
patch only takes a minute to merge with b4 if no-one reviews or tests it, but that's not really desirable.
I have not said that either. I said reviewing and merging those are noise compared to any complex patch. Testing should be done by the author comparing codegen.
Quoted 2 lines
Part of what I'm trying to measure is the "and useful" bit because that's not a given.
It is useful since it makes intent clear. It also catches actual bugs, which is even more valuable.
Quoted 5 lines
Well, you know, subsystems are very different in terms of the amount of patches a maintainer has to process per release cycle of the kernel. If a maintainer is close to capacity, additional patches, however trivial, become a problem. If a maintainer has spare cycles, trivial patches may look easy.
First of all, voluntary maintainers choose their own workload. Furthermore, we already measure capacity in the MAINTAINERS file:
maintainers can state they can only handle a few patches. Finally, if someone does not have time for a trivial patch, they are very unlikely to have any time to review big ones.
Quoted 2 lines
You seem to be saying that because you find it easy to merge trivial patches, everyone should.
Again, I have not said anything of the sort.
Cheers,
Miguel
Quoted 4 lines · Finn Thain
I'm saying that supporting the official language spec makes more sense than attempting to support a multitude of divergent interpretations of the spec (i.e. gcc, clang, coverity etc.)
Making the kernel strictly conforming is a ship that sailed long ago, for several reasons. Anyway, supporting several compilers and other tools, regardless of extensions, is valuable.
Quoted 3 lines
I'm also saying that the reason why we use -std=gnu89 is that existing code was written in that language, not in ad hoc languages comprised of collections of extensions that change with every release.
No, we aren't particularly tied to gnu89 or anything like that. We could actually go for gnu11 already, since the minimum GCC and Clang support it. Even if a bit of code needs fixing, that shouldn't be a problem if someone puts the work.
In other words, the kernel code is not frozen, nor are the features it uses from compilers. They do, in fact, change from time to time.
Quoted 1 line
Thank you for checking. I found a free version that's only 6 weeks old:
You're welcome! There are quite a few new attributes coming, mostly following C++ ones.
Quoted 2 lines
It will be interesting to see whether 6.7.11.5 changes once the various implementations reach agreement.
Not sure what you mean. The standard does not evolve through implementations' agreement (although standardizing existing practice is one of the best arguments to back a change).
Cheers,
Miguel
Re: [PATCH 127/141] staging: qlge: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 15 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- drivers/staging/qlge/qlge_main.c | 1 + 1 file changed, 1 insertion(+)drivers/staging/qlge/qlge_main.c +0
-0
drivers/staging/qlge/qlge_main.c static void ql_categorize_rx_err(struct ql_adapter *qdev, u8 rx_err, · line 1391
Quoted 7 lines
drivers/staging/qlge/qlge_main.c +1
-0@@ -1385,6 +1385,7 @@ static void ql_categorize_rx_err(struct ql_adapter *qdev, u8 rx_err,break ;case IB_MAC_IOCB_RSP_ERR_CRC : stats->rx_crc_err++; +break ;default :break ; }
In this instance, it think it would be more appropriate to remove the "default" case.
James Bottomley
maintainerQuoted 10 lines · Kees Cook
Quoted 5 lines · James Bottomley
Really, no ... something which produces no improvement has no value at all ... we really shouldn't be wasting maintainer time with it because it has a cost to merge. I'm not sure we understand where the balance lies in value vs cost to merge but I am confident in the zero value case.
What? We can't measure how many future bugs aren't introduced because the kernel requires explicit case flow-control statements for all new code.
No but we can measure how vulnerable our current coding habits are to the mistake this warning would potentially prevent. I don't think it's wrong to extrapolate that if we had no instances at all of prior coding problems we likely wouldn't have any in future either making adopting the changes needed to enable the warning valueless ... that's the zero value case I was referring to above.
Now, what we have seems to be about 6 cases (at least what's been shown in this thread) where a missing break would cause potentially user visible issues. That means the value of this isn't zero, but it's not a no-brainer massive win either. That's why I think asking what we've invested vs the return isn't a useless exercise.
Quoted 7 lines
We already enable -Wimplicit-fallthrough globally, so that's not the discussion. The issue is that Clang is (correctly) even more strict than GCC for this, so these are the remaining ones to fix for full Clang coverage too.
People have spent more time debating this already than it would have taken to apply the patches. :)
You mean we've already spent 90% of the effort to come this far so we might as well go the remaining 10% because then at least we get some return? It's certainly a clinching argument in defence procurement ...
Quoted 7 lines
This is about robustness and language wrangling. It's a big code- base, and this is the price of our managing technical debt for permanent robustness improvements. (The numbers I ran from Gustavo's earlier patches were that about 10% of the places adjusted were identified as legitimate bugs being fixed. This final series may be lower, but there are still bugs being found from it -- we need to finish this and shut the door on it for good.)
I got my six patches by analyzing the lwn.net report of the fixes that was cited which had 21 of which 50% didn't actually change the emitted code, and 25% didn't have a user visible effect.
But the broader point I'm making is just because the compiler people come up with a shiny new warning doesn't necessarily mean the problem it's detecting is one that causes us actual problems in the code base. I'd really be happier if we had a theory about what classes of CVE or bug we could eliminate before we embrace the next new warning.
James
Quoted 23 lines · James Bottomley
Quoted 15 lines · Miguel Ojeda
Quoted 4 lines · James Bottomley
It's not about the risk of the changes it's about the cost of implementing them. Even if you discount the producer time (which someone gets to pay for, and if I were the engineering manager, I'd be unhappy about), the review/merge/rework time is pretty
Quoted 8 lines
significant in exchange for six minor bug fixes. Fine, when a new compiler warning comes along it's certainly reasonable to see if we can benefit from it and the fact that the compiler people think it's worthwhile is enough evidence to assume this initially. But at some point you have to ask whether that assumption is supported by the evidence we've accumulated over the time we've been using it. And if the evidence doesn't support it perhaps it is time to stop the experiment.
Quoted 2 lines
Maintainers routinely review 1-line trivial patches, not to mention internal API changes, etc.
We're also complaining about the inability to recruit maintainers:
https://www.theregister.com/2020/06/30/hard_to_find_linux_maintainers_says_torvalds/
Quoted 8 lines
And burn out:
The whole crux of your argument seems to be maintainers' time isn't important so we should accept all trivial patches ... I'm pushing back on that assumption in two places, firstly the valulessness of the time and secondly that all trivial patches are valuable.
You're assuming burn out or recruitment problems is due to patch workload or too many "trivial" patches.
In my experience, "other maintainers" is by far the biggest cause of burn out for my kernel maintenance work.
Certainly arguing with a maintainer about some obviously-correct patch series must be a good example of this.
Sean
Quoted 3 lines · James Bottomley
Quoted 2 lines · Miguel Ojeda
On Mon, Nov 23, 2020 at 4:58 PM James Bottomley
<[email protected]> wrote:
...
Quoted 9 lines
Quoted 4 lines
But if we do the math, for an author, at even 1 minute per line change and assuming nothing can be automated at all, it would take 1 month of work. For maintainers, a couple of trivial lines is noise compared to many other patches.
So you think a one line patch should take one minute to produce ... I really don't think that's grounded in reality. I suppose a one line patch only takes a minute to merge with b4 if no-one reviews or tests it, but that's not really desirable.
In my practice most of the one line patches were either to fix or to introduce quite interesting issues.
1 minute is 2-3 orders less than usually needed for such patches. That's why I don't like churn produced by people who often even didn't compile their useful contributions.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 7 lines · James Bottomley
Quoted 5 lines · Kees Cook
We already enable -Wimplicit-fallthrough globally, so that's not the discussion. The issue is that Clang is (correctly) even more strict than GCC for this, so these are the remaining ones to fix for full Clang coverage too.
Quoted 6 lines
Quoted 2 lines
People have spent more time debating this already than it would have taken to apply the patches. :)
You mean we've already spent 90% of the effort to come this far so we might as well go the remaining 10% because then at least we get some return? It's certainly a clinching argument in defence procurement ...
So developers and distributions using Clang can't have -Wimplicit-fallthrough enabled because GCC is less strict (which has been shown in this thread to lead to bugs)? We'd like to have nice things too, you know.
I even agree that most of the churn comes from
case 0:
++x;
default:
break;
which I have a patch for: https://reviews.llvm.org/D91895. I agree that can never lead to bugs. But that's not the sole case of this series, just most of them.
Though, note how the reviewer (C++ spec editor and clang front end owner) in https://reviews.llvm.org/D91895 even asks in that review how maybe a new flag would be more appropriate for a watered down/stylistic variant of the existing behavior. And if the current wording of Documentation/process/deprecated.rst around "fallthrough" is a straightforward rule of thumb, I kind of agree with him.
Quoted 9 lines
Quoted 8 lines
This is about robustness and language wrangling. It's a big code- base, and this is the price of our managing technical debt for permanent robustness improvements. (The numbers I ran from Gustavo's earlier patches were that about 10% of the places adjusted were identified as legitimate bugs being fixed. This final series may be lower, but there are still bugs being found from it -- we need to finish this and shut the door on it for good.)
Quoted 6 lines
I got my six patches by analyzing the lwn.net report of the fixes that was cited which had 21 of which 50% didn't actually change the emitted code, and 25% didn't have a user visible effect.
But the broader point I'm making is just because the compiler people come up with a shiny new warning doesn't necessarily mean the problem
That's not what this is though; you're attacking a strawman. I'd encourage you to bring that up when that actually occurs, unlike this case since it's actively hindering getting -Wimplicit-fallthrough enabled for Clang. This is not a shiny new warning; it's already on for GCC and has existed in both compilers for multiple releases.
And I'll also note that warnings are warnings and not errors because they cannot be proven to be bugs in 100% of cases, but they have led to bugs in the past. They require a human to review their intent and remove ambiguities. If 97% of cases would end in a break ("Expert C
Programming: Deep C Secrets" - Peter van der Linden), then it starts to look to me like a language defect; certainly an incorrectly chosen default. But the compiler can't know those 3% were intentional, unless you're explicit for those exceptional cases.
Quoted 3 lines
it's detecting is one that causes us actual problems in the code base. I'd really be happier if we had a theory about what classes of CVE or bug we could eliminate before we embrace the next new warning.
We don't generally file CVEs and waiting for them to occur might be too reactive, but I agree that pointing to some additional documentation in commit messages about how a warning could lead to a bug would make it clearer to reviewers why being able to enable it treewide, even if there's no bug in their particular subsystem, is in the general interest of the commons.
Quoted 5 lines · James Bottomley
We're also complaining about the inability to recruit maintainers:
https://www.theregister.com/2020/06/30/hard_to_find_linux_maintainers_says_torvalds/
Quoted 8 lines
And burn out:
The whole crux of your argument seems to be maintainers' time isn't important so we should accept all trivial patches ... I'm pushing back on that assumption in two places, firstly the valulessness of the time and secondly that all trivial patches are valuable.
It's critical to the longevity of any open source project that there are not single points of failure. If someone is not expendable or replaceable (or claims to be) then that's a risk to the project and a bottleneck. Not having a replacement in training or some form of redundancy is short sighted.
If trivial patches are adding too much to your workload, consider training a co-maintainer or asking for help from one of your reviewers whom you trust. I don't doubt it's hard to find maintainers, but existing maintainers should go out of their way to entrust co-maintainers especially when they find their workload becomes too high. And reviewing/picking up trivial patches is probably a great way to get started. If we allow too much knowledge of any one subsystem to collect with one maintainer, what happens when that maintainer leaves the community (which, given a finite lifespan, is an inevitability)?
Signature · 2 lines
Thanks, ~Nick Desaulniers
Re: [PATCH 062/141] HID: usbhid: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a couple of warnings by explicitly adding a couple of break statements instead of letting the code fall through to the next case.
--- drivers/hid/usbhid/hid-core.c | 2 ++ 1 file changed, 2 insertions(+)drivers/hid/usbhid/hid-core.c +1
-0@@ -438,6 +438,7 @@ static void hid_irq_out(struct urb *urb)break ;case -ESHUTDOWN :/* unplug */ unplug =1 ; +break ;case -EILSEQ :/* protocol error or unplug */ case -EPROTO :/* protocol error or unplug */ case -ECONNRESET :/* unlink */
drivers/hid/usbhid/hid-core.c static void hid_ctrl(struct urb *urb) · line 496
Quoted 7 lines
drivers/hid/usbhid/hid-core.c +1
-0@@ -489,6 +490,7 @@ static void hid_ctrl(struct urb *urb)break ;case -ESHUTDOWN :/* unplug */ unplug =1 ; +break ;case -EILSEQ :/* protocol error or unplug */ case -EPROTO :/* protocol error or unplug */ case -ECONNRESET :/* unlink */
Applied, thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs
Jiri Kosina
maintainerRe: [PATCH 063/141] HID: input: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 15 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a goto statement instead of letting the code fall through to the next case.
--- drivers/hid/hid-input.c | 1 + 1 file changed, 1 insertion(+)drivers/hid/hid-input.c +0
-0
drivers/hid/hid-input.c static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel · line 748
Quoted 6 lines
drivers/hid/hid-input.c +1
-0@@ -743,6 +743,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel field->flags |=HID_MAIN_ITEM_RELATIVE ;break ; } + goto unknown;default : goto unknown;
This makes my eyes hurt :) But adding the annotation would be ugly as well, so let me just take it as-is.
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
RE: [PATCH 063/141] HID: input: Fix fall-through warnings for Clang
From: Jiri Kosina <[email protected]>
Quoted 23 lines
Sent: 25 November 2020 13:04
Quoted 20 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a goto statement instead of letting the code fall through to the next case.
--- drivers/hid/hid-input.c | 1 + 1 file changed, 1 insertion(+)drivers/hid/hid-input.c +1
-0@@ -743,6 +743,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel field->flags |=HID_MAIN_ITEM_RELATIVE ;break ; } + goto unknown;
Quoted 4 lines
drivers/hid/hid-input.c static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel · line 748
Quoted 1 line
drivers/hid/hid-input.c +0
-0default : goto unknown;This makes my eyes hurt :) But adding the annotation would be ugly as well, so let me just take it as-is.
case HID_GD_RFKILL_BTN:
/* MS wireless radio ctl extension, also check CA */
if (field->application == HID_GD_WIRELESS_RADIO_CTLS) {
map_key_clear(KEY_RFKILL);
/* We need to simulate the btn release */
field->flags |= HID_MAIN_ITEM_RELATIVE;
break;
}It might be best to invert the condition and de-indent the code.
case HID_GD_RFKILL_BTN:
/* MS wireless radio ctl extension, also check CA */
if (field->application != HID_GD_WIRELESS_RADIO_CTLS)
goto unknown;
map_key_clear(KEY_RFKILL);
/* We need to simulate the btn release */
field->flags |= HID_MAIN_ITEM_RELATIVE;
break;
David-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Jakub Kicinski
maintainerQuoted 6 lines · On Wed, 25 Nov 2020 04:24:27 -0800 Nick Desaulniers wrote:
I even agree that most of the churn comes from
case 0:
++x;
default:
break;
And just to spell it out,
case ENUM_VALUE1:
bla(); break; case ENUM_VALUE2: bla(); default: break;
is a fairly idiomatic way of indicating that not all values of the enum are expected to be handled by the switch statement.
I really hope the Clang folks are reasonable and merge your patch.
Quoted 10 lines
If trivial patches are adding too much to your workload, consider training a co-maintainer or asking for help from one of your reviewers whom you trust. I don't doubt it's hard to find maintainers, but existing maintainers should go out of their way to entrust co-maintainers especially when they find their workload becomes too high. And reviewing/picking up trivial patches is probably a great way to get started. If we allow too much knowledge of any one subsystem to collect with one maintainer, what happens when that maintainer leaves the community (which, given a finite lifespan, is an inevitability)?
The burn out point is about enjoying your work and feeling that it matters. It really doesn't make much difference if you're doing something you don't like for 12 hours every day or only in shifts with another maintainer. You'll dislike it either way.
Applying a real patch set and then getting a few follow ups the next day for trivial coding things like fallthrough missing or static missing, just because I didn't have the full range of compilers to check with before applying makes me feel pretty shitty, like I'm not doing a good job. YMMV.
Quoted 6 lines · On Wed, 25 Nov 2020 04:24:27 -0800 Nick Desaulniers wrote:
I even agree that most of the churn comes from
case 0:
++x;
default:
break;
And just to spell it out,
case ENUM_VALUE1:
bla(); break; case ENUM_VALUE2: bla(); default: break;
is a fairly idiomatic way of indicating that not all values of the enum are expected to be handled by the switch statement.
I really hope the Clang folks are reasonable and merge your patch.
Quoted 10 lines
If trivial patches are adding too much to your workload, consider training a co-maintainer or asking for help from one of your reviewers whom you trust. I don't doubt it's hard to find maintainers, but existing maintainers should go out of their way to entrust co-maintainers especially when they find their workload becomes too high. And reviewing/picking up trivial patches is probably a great way to get started. If we allow too much knowledge of any one subsystem to collect with one maintainer, what happens when that maintainer leaves the community (which, given a finite lifespan, is an inevitability)?
The burn out point is about enjoying your work and feeling that it matters. It really doesn't make much difference if you're doing something you don't like for 12 hours every day or only in shifts with another maintainer. You'll dislike it either way.
Applying a real patch set and then getting a few follow ups the next day for trivial coding things like fallthrough missing or static missing, just because I didn't have the full range of compilers to check with before applying makes me feel pretty shitty, like I'm not doing a good job. YMMV.
Quoted 11 lines · Jakub Kicinski
And just to spell it out,
case
ENUM_VALUE1:bla(); break; case ENUM_VALUE2: bla(); default: break;
Quoted 2 lines
is a fairly idiomatic way of indicating that not all values of the enum are expected to be handled by the switch statement.
It looks like a benign typo to me -- ENUM_VALUE2 does not follow the same pattern like ENUM_VALUE1. To me, the presence of the default is what indicates (explicitly) that not everything is handled.
Quoted 5 lines
Applying a real patch set and then getting a few follow ups the next day for trivial coding things like fallthrough missing or static missing, just because I didn't have the full range of compilers to check with before applying makes me feel pretty shitty, like I'm not doing a good job. YMMV.
The number of compilers, checkers, static analyzers, tests, etc. we use keeps going up. That, indeed, means maintainers will miss more things (unless maintainers do more work than before). But catching bugs before they happen is *not* a bad thing.
Perhaps we could encourage more rebasing in -next (while still giving credit to bots and testers) to avoid having many fixing commits afterwards, but that is orthogonal.
I really don't think we should encourage the feeling that a maintainer is doing a bad job if they don't catch everything on their reviews. Any review is worth it. Maintainers, in the end, are just the "guaranteed" reviewers that decide when the code looks reasonable enough. They should definitely not feel pressured to be perfect.
Cheers,
Miguel
Quoted 5 lines · James Bottomley
Now, what we have seems to be about 6 cases (at least what's been shown in this thread) where a missing break would cause potentially user visible issues. That means the value of this isn't zero, but it's not a no-brainer massive win either. That's why I think asking what we've invested vs the return isn't a useless exercise.
The number is much higher[1]. If it were 6 in the entire history of the kernel, I would agree with you. :) Some were fixed _before_ Gustavo's effort too, which I also count towards the idea of "this is a dangerous weakness in C, and now we have stopped it forever."
Quoted 5 lines
But the broader point I'm making is just because the compiler people come up with a shiny new warning doesn't necessarily mean the problem it's detecting is one that causes us actual problems in the code base. I'd really be happier if we had a theory about what classes of CVE or bug we could eliminate before we embrace the next new warning.
But we did! It was long ago justified and documented[2], and even links to the CWE[3] for it. This wasn't random joy over discovering a new warning we could turn on, this was turning on a warning that the compiler folks finally gave us to handle an entire class of flaws. If we need to update the code-base to address it not a useful debate -- that was settled already, even if you're only discovering it now. :P. This last patch set is about finishing that work for Clang, which is correctly even more strict than GCC.
-Kees
[1] https://outflux.net/slides/2019/lss/kspp.pdf calls out specific
numbers (about 6.5% of the patches fixed missing breaks):
v4.19: 3 of 129
v4.20: 2 of 59
v5.0: 3 of 56
v5.1: 10 of 100
v5.2: 6 of 71
v5.3: 7 of 69
And in the history of the kernel, it's been an ongoing source of
flaws:
$ l --no-merges | grep -i 'missing break' | wc -l
185
The frequency of such errors being "naturally" found was pretty
steady until the static checkers started warning, and then it was
on the rise, but the full effort flushed the rest out, and now it's
dropped to almost zero:
1 v2.6.12
3 v2.6.16.28
1 v2.6.17
1 v2.6.19
2 v2.6.21
1 v2.6.22
3 v2.6.24
3 v2.6.29
1 v2.6.32
1 v2.6.33
1 v2.6.35
4 v2.6.36
3 v2.6.38
2 v2.6.39
7 v3.0
2 v3.1
2 v3.2
2 v3.3
3 v3.4
1 v3.5
8 v3.6
7 v3.7
3 v3.8
6 v3.9
3 v3.10
2 v3.11
5 v3.12
5 v3.13
2 v3.14
4 v3.15
2 v3.16
3 v3.17
2 v3.18
2 v3.19
1 v4.0
2 v4.1
5 v4.2
4 v4.5
5 v4.7
6 v4.8
1 v4.9
3 v4.10
2 v4.11
6 v4.12
3 v4.13
2 v4.14
5 v4.15
2 v4.16
7 v4.18
2 v4.19
6 v4.20
3 v5.0
12 v5.1
3 v5.2
4 v5.3
2 v5.4
1 v5.8
And the reason it's fully zero, is because we still have the cases we're
cleaning up right now. Even this last one from v5.8 is specifically of
the same type this series addresses:
case 4:
color_index = TrueCModeIndex;
+ break;
default:
return;
}[2] https://www.kernel.org/doc/html/latest/process/deprecated.html#implicit-switch-case-fall-through
All switch/case blocks must end in one of: break; fallthrough; continue; goto <label>; return [expression];
[3] https://cwe.mitre.org/data/definitions/484.html
Signature · 1 line
Kees Cook
Quoted 5 lines · Nick Desaulniers
So developers and distributions using Clang can't have -Wimplicit-fallthrough enabled because GCC is less strict (which has been shown in this thread to lead to bugs)? We'd like to have nice things too, you know.
Apparently the GCC developers don't want you to have "nice things" either. Do you think that the kernel should drop gcc in favour of clang? Or do you think that a codebase can somehow satisfy multiple checkers and their divergent interpretations of the language spec?
Quoted 3 lines
This is not a shiny new warning; it's already on for GCC and has existed in both compilers for multiple releases.
Perhaps you're referring to the compiler feature that lead to the ill-fated, tree-wide /* fallthrough */ patch series.
When the ink dries on the C23 language spec and the implementations figure out how to interpret it then sure, enforce the warning for new code -- the cost/benefit analysis is straight forward. However, the case for patching existing mature code is another story.
Quoted 6 lines · Jakub Kicinski
Applying a real patch set and then getting a few follow ups the next day for trivial coding things like fallthrough missing or static missing, just because I didn't have the full range of compilers to check with before applying makes me feel pretty shitty, like I'm not doing a good job. YMMV.
I understand. Everyone feels that way, except maybe Bond villains and robots. My advice in that case is don't take it personally. We're working with a language that's more error prone relative to others. While one would like to believe they are flawless, over time they can't beat the aggregate statistics. A balance between Imposter Syndrome and Dunning Kruger is walked by all software developers, and the fear of making mistakes in public is one of the number one reasons folks don't take the plunge contributing to open source software or even the kernel. My advice to them is "don't sweat the small stuff."
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 3 lines · Finn Thain
Or do you think that a codebase can somehow satisfy multiple checkers and their divergent interpretations of the language spec?
Have we found any cases yet that are divergent? I don't think so. It sounds to me like GCC's cases it warns for is a subset of Clang's. Having additional coverage with Clang then should ensure coverage for both.
Quoted 11 lines
Quoted 3 lines
This is not a shiny new warning; it's already on for GCC and has existed in both compilers for multiple releases.
Perhaps you're referring to the compiler feature that lead to the ill-fated, tree-wide /* fallthrough */ patch series.
When the ink dries on the C23 language spec and the implementations figure out how to interpret it then sure, enforce the warning for new code -- the cost/benefit analysis is straight forward. However, the case for patching existing mature code is another story.
I don't think we need to wait for the ink to dry on the C23 language spec to understand that implicit fallthrough is an obvious defect of the C language. While the kernel is a mature codebase, it's not immune to bugs. And its maturity has yet to slow its rapid pace of development.
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 4 lines · Miguel Ojeda
I have said *authoring* lines of *this* kind takes a minute per line.
Specifically: lines fixing the fallthrough warning mechanically and repeatedly where the compiler tells you to, and doing so full-time for a month.
<snip>
Quoted 1 line
It is useful since it makes intent clear.
To make the intent clear, you have to first be certain that you
understand the intent; otherwise by adding either a break or a fallthrough to suppress the warning you are just destroying the information that "the intent of this code is unknown".
Figuring out the intent of a piece of unfamiliar code takes more
than 1 minute; just because
case foo:
thing;
case bar:
break;
produces identical code to
case foo:
thing;
break;
case bar:
break;
doesn't mean that *either* is correct — maybe the author meant
to write
case foo:
return thing;
case bar:
break; and by inserting that break you've destroyed the marker that would direct someone who knew what the code was about to look at that point in the code and spot the problem.
Thus, you *always* have to look at more than just the immediate
mechanical context of the code, to make a proper judgement that yes, this was the intent. If you think that that sort of thing can be done in an *average* time of one minute, then I hope you stay away from code I'm responsible for!
One minute would be an optimistic target for code that, as the
maintainer, one is already somewhat familiar with. For code that you're seeing for the first time, as is usually the case with the people doing these mechanical fix-a-warning patches, it's completely unrealistic.
A warning is only useful because it makes you *think* about the
code. If you suppress the warning without doing that thinking, then you made the warning useless; and if the warning made you think about code that didn't *need* it, then the warning was useless from the start.
So make your mind up: does Clang's stricter -Wimplicit-fallthrough
flag up code that needs thought (in which case the fixes take effort both to author and to review) or does it flag up code that can be mindlessly "fixed" (in which case the warning is worthless)? Proponents in this thread seem to be trying to have it both ways.
-ed
Quoted 2 lines · Kees Cook
I still think this isn't right -- it's a case statement that runs off the end without an explicit flow control determination.
Proves too much — for instance
case foo:
case bar:
thing;
break;doesn't require a fallthrough; after case foo:, and afaik no-one is suggesting it should. Yet it, too, is "a case statement that runs off the end without an explicit flow control determination".
-ed
Quoted 7 lines · Nick Desaulniers
Quoted 3 lines · Finn Thain
Or do you think that a codebase can somehow satisfy multiple checkers and their divergent interpretations of the language spec?
Have we found any cases yet that are divergent? I don't think so.
There are many implementations, so I think you are guaranteed to find more divergence if you look. That's because the spec is full of language like
this: "implementations are encouraged not to emit a diagnostic" and "implementations are encouraged to issue a diagnostic".
Some implementations will decide to not emit (under the premise that vast amounts of existing code would have to get patched until the compiler goes quiet) whereas other implementations will decide to emit (under the premise that the author is doing the checking and not the janitor or the packager).
Quoted 4 lines
It sounds to me like GCC's cases it warns for is a subset of Clang's. Having additional coverage with Clang then should ensure coverage for both.
If that claim were true, the solution would be simple. (It's not.)
For the benefit of projects that enable -Werror and projects that nominated gcc as their preferred compiler, clang would simply need a flag to enable conformance with gcc by suppressing those additional warnings that clang would normally produce.
This simple solution is, of course, completely unworkable, since it would force clang to copy some portion of gcc's logic (rewritten under LLVM's unique license) and then to track future changes to that portion of gcc indefinitely.
Quoted 6 lines · Nick Desaulniers
Quoted 3 lines · Finn Thain
Or do you think that a codebase can somehow satisfy multiple checkers and their divergent interpretations of the language spec?
Have we found any cases yet that are divergent? I don't think so.
You mean, aside from -Wimplicit-fallthrough? I'm glad you asked. How about -Wincompatible-pointer-types and -Wframe-larger-than?
All of the following files have been affected by divergent diagnostics produced by clang and gcc.
arch/arm64/include/asm/neon-intrinsics.h arch/powerpc/xmon/Makefile drivers/gpu/drm/i915/Makefile drivers/gpu/drm/i915/i915_utils.h drivers/staging/media/atomisp/pci/atomisp_subdev.c fs/ext4/super.cinclude/trace/events/qla.h net/mac80211/rate.ctools/lib/string.c tools/perf/util/setup.py tools/scripts/Makefile.include
And if I searched for 'smatch' or 'coverity' instead of 'clang' I'd probably find more divergence.
Here are some of the relevant commits.
0738c8b5915c7eaf1e6007b441008e8f3b4604439c87156cce5a63735d1218f0096a65c50a7a32aababaab2f473817f173a2d08e410c25abf5ed0f6b065e5e559555e2f100bc95792a8ef1b609bbe13093f56de259376d7e4fff2b2d104082e1fa66e2376c4798d3f08b81c2c52936b10e0fa872590c96aeb7a313d84e853049062011d78cb04b6decd12f5c093b75ef5995ea35d7f6bdb6c7b32a42a1999813
And before you object, "but -Wconstant-logical-operand is a clang-only warning! it can't be divergent with gcc!", consider that the special cases added to deal with clang-only warnings have to be removed when gcc catches up, which is more churn. Now multiply that by the number of checkers you care about.
Quoted 5 lines · Edward Cree
To make the intent clear, you have to first be certain that you
understand the intent; otherwise by adding either a break or a fallthrough to suppress the warning you are just destroying the information that "the intent of this code is unknown".
If you don't know what the intent of your own code is, then you *already* have a problem in your hands.
Quoted 12 lines
Figuring out the intent of a piece of unfamiliar code takes more
than 1 minute; just becausecase foo: thing; case bar: break; produces identical code to case foo: thing; break; case bar: break;
Quoted 1 line
doesn't mean that *either* is correct — maybe the author meant
What takes 1 minute is adding it *mechanically* by the author, i.e. so that you later compare whether codegen is the same.
Quoted 8 lines
to write
case foo: return thing; case bar: break;and by inserting that break you've destroyed the marker that would direct someone who knew what the code was about to look at that point in the code and spot the problem.
Then it means you already have a bug. This patchset gives the maintainer a chance to notice it, which is a good thing. The "you've destroyed the market" claim is bogus, because:
1. you were not looking into it
2. you didn't notice the bug so far
3. is implicit -- harder to spot
4. is only useful if you explicitly take a look at this kind of bug.
So why don't you do it now?
Quoted 3 lines
Thus, you *always* have to look at more than just the immediate
mechanical context of the code, to make a proper judgement that yes, this was the intent.
I find that is the responsibility of the maintainers and reviewers for tree-wide patches like this, assuming they want. They can also keep the behavior (and the bugs) without spending time. Their choice.
Quoted 3 lines
If you think that that sort of thing
can be done in an *average* time of one minute, then I hope you stay away from code I'm responsible for!
Please don't accuse others of recklessness or incompetence, especially if you didn't understand what they said.
Quoted 5 lines
A warning is only useful because it makes you *think* about the
code. If you suppress the warning without doing that thinking, then you made the warning useless; and if the warning made you think about code that didn't *need* it, then the warning was useless from the start.
We are not suppressing the warning. Quite the opposite, in fact.
Quoted 3 lines
So make your mind up: does Clang's stricter -Wimplicit-fallthrough
flag up code that needs thought (in which case the fixes take effort both to author and to review)
As I said several times already, it does take time to review if the maintainer wants to take the chance to see if they had a bug to begin with, but it does not require thought for the author if they just go for equivalent codegen.
Quoted 4 lines
or does it flag up code
that can be mindlessly "fixed" (in which case the warning is worthless)? Proponents in this thread seem to be trying to have it both ways.
A warning is not worthless just because you can mindlessly fix it. There are many counterexamples, e.g. many checkpatch/lint/lang-format/indentation warnings, functional ones like the if (a = b) warning...
Cheers,
Miguel
Hi Miguel,
Quoted 8 lines · Miguel Ojeda
Quoted 4 lines · Edward Cree
To make the intent clear, you have to first be certain that you
understand the intent; otherwise by adding either a break or a fallthrough to suppress the warning you are just destroying the information that "the intent of this code is unknown".If you don't know what the intent of your own code is, then you *already* have a problem in your hands.
The maintainer is not necessarily the owner/author of the code, and thus may not know the intent of the code.
Quoted 9 lines
Quoted 4 lines
or does it flag up code
that can be mindlessly "fixed" (in which case the warning is worthless)? Proponents in this thread seem to be trying to have it both ways.A warning is not worthless just because you can mindlessly fix it. There are many counterexamples, e.g. many checkpatch/lint/lang-format/indentation warnings, functional ones like the
if (a = b)warning...
BTW, you cannot mindlessly fix the latter, as you cannot know if "(a == b)" or "((a = b))" was intended, without understanding the code (and the (possibly unavailable) data sheet, and the hardware, ...).
P.S. So far I've stayed out of this thread, as I like it if the compiler
flags possible mistakes. After all I was the one fixing new "may be used uninitialized" warnings thrown up by gcc-4.1, until (a bit later than) support for that compiler was removed...
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 22 lines · Geert Uytterhoeven
Hi Miguel,
Quoted 8 lines · Miguel Ojeda
Quoted 4 lines · Edward Cree
To make the intent clear, you have to first be certain that you
understand the intent; otherwise by adding either a break or a fallthrough to suppress the warning you are just destroying the information that "the intent of this code is unknown".If you don't know what the intent of your own code is, then you *already* have a problem in your hands.
The maintainer is not necessarily the owner/author of the code, and thus may not know the intent of the code.
Quoted 5 lines
Quoted 4 lines
or does it flag up code
that can be mindlessly "fixed" (in which case the warning is worthless)? Proponents in this thread seem to be trying to have it both ways.
Quoted 9 lines
Quoted 4 lines
A warning is not worthless just because you can mindlessly fix it. There are many counterexamples, e.g. many checkpatch/lint/lang-format/indentation warnings, functional ones like the
if (a = b)warning...BTW, you cannot mindlessly fix the latter, as you cannot know if "(a == b)" or "((a = b))" was intended, without understanding the code (and the (possibly unavailable) data sheet, and the hardware, ...).
to allow assignments in if statements was clearly a mistake and if you need outside information to understand the code, your code is the issue already.
Quoted 20 lines
P.S. So far I've stayed out of this thread, as I like it if the compiler
flags possible mistakes. After all I was the one fixing new "may be used uninitialized" warnings thrown up by gcc-4.1, until (a bit later than) support for that compiler was removed...Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 3 lines · Geert Uytterhoeven
The maintainer is not necessarily the owner/author of the code, and thus may not know the intent of the code.
Agreed, I was not blaming maintainers -- just trying to point out that the problem is there :-)
In those cases, it is still very useful: we add the fallthrough and a comment saying FIXME: fallthrough intended? Figure this out.... Thus a previous unknown unknown is now a known unknown. And no new unknown unknowns will be introduced since we enabled the warning globally.
Quoted 3 lines
BTW, you cannot mindlessly fix the latter, as you cannot know if "(a == b)" or "((a = b))" was intended, without understanding the code (and the (possibly unavailable) data sheet, and the hardware, ...).
That's right, I was referring to the cases where the compiler saves someone time from a typo they just made.
Cheers,
Miguel
Re: [PATCH 134/141] video: fbdev: lxfb_ops: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 3 lines · Gustavo A. R. Silva
Absolutely. We'll never know how many bugs this will catch in the future decades of kernel development, before the code is even committed/submitted. :)
A little bit OT here, but what are the plans for Geode in general as there was discussion around the fact that Debian will be one of the last platforms to drop i386 arch support.
Thank you
Jarkko Sakkinen
maintainerRe: [PATCH 131/141] tpm: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 39 lines · Gustavo A. R. Silva
Quoted 31 lines · Jarkko Sakkinen
Quoted 30 lines · Jarkko Sakkinen
Quoted 15 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
---
drivers/char/tpm/eventlog/tpm1.c | 1 +1 file changed, 1 insertion(+)drivers/char/tpm/eventlog/tpm1.c +0
-0@@ -210,6 +210,7 @@ static int get_event_name(char *dest, struct tcpa_event *event,Quoted 11 lines
default:
break;
}
+ break;
default:
break;
}Signature · 1 line
2.27.0Reviewed-by Jarkko Sakkinen <[email protected]>Quoted 1 line
Quoted 1 line
Who is picking these patches?
I can take it in my tree for 5.11 if people are OK with that. :)
Quoted 3 lines
Quoted 2 lines
/Jarkko
Quoted 7 lines
Quoted 3 lines
I mean
Reviewed-by Jarkko Sakkinen <[email protected]>Thanks, Jarkko.
--
Gustavo
keyring:
TPM:
Looks good?
/Jarkko
Herbert Xu
maintainerRe: [PATCH 075/141] crypto: ccree - Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 9 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of letting the code fall through to the next case.
--- drivers/crypto/ccree/cc_cipher.c | 3 +++ 1 file changed, 3 insertions(+)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH 109/141] net: netrom: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of letting the code fall through to the next case.
--- net/netrom/nr_route.c | 4 ++++ 1 file changed, 4 insertions(+)net/netrom/nr_route.c +1
-0@@ -266,6 +266,7 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic, fallthrough;case 2 :re_sort_routes (nr_node,0 ,1 ); +break ;case 1 :break ; }
net/netrom/nr_route.c static int nr_del_node(ax25_address *callsign, ax25_address *neighbour, struct n · line 363
Quoted 4 lines
net/netrom/nr_route.c +1
-0@@ -359,6 +360,7 @@ static int nr_del_node(ax25_address *callsign, ax25_address *neighbour, struct n fallthrough;case 1 : nr_node->routes[1 ] = nr_node->routes[2 ]; + fallthrough;
Make this one a break like the others.
Quoted 12 lines
net/netrom/nr_route.c +1
-0case 2 :break ; }@@ -482,6 +484,7 @@ static int nr_dec_obs(void) fallthrough;case 1 : s->routes[1 ] = s->routes[2 ]; +break ;case 2 :break ; }
net/netrom/nr_route.c void nr_rt_device_down(struct net_device *dev) · line 538
Quoted 7 lines
net/netrom/nr_route.c +1
-0@@ -529,6 +532,7 @@ void nr_rt_device_down(struct net_device *dev) fallthrough;case 1 : t->routes[1 ] = t->routes[2 ]; +break ;case 2 :break ; }
regards,
dan carpenter
Re: [PATCH 127/141] staging: qlge: Fix fall-through warnings for Clang
In reply to Benjamin PoirierQuoted 11 lines · Benjamin Poirier
Quoted 10 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- drivers/staging/qlge/qlge_main.c | 1 + 1 file changed, 1 insertion(+)
Quoted 15 lines
drivers/staging/qlge/qlge_main.c static void ql_categorize_rx_err(struct ql_adapter *qdev, u8 rx_err, · line 1391
Quoted 12 lines
drivers/staging/qlge/qlge_main.c +1
-0@@ -1385,6 +1385,7 @@ static void ql_categorize_rx_err(struct ql_adapter *qdev, u8 rx_err,break ;case IB_MAC_IOCB_RSP_ERR_CRC : stats->rx_crc_err++; +break ;default :break ; }In this instance, it think it would be more appropriate to remove the "default" case.
There are checkers which complain about that. (As a static checker developer myself, I think complaining about missing default cases is a waste of everyone's time).
regards,
dan carpenter
Gustavo,
Quoted 2 lines
This series aims to fix almost all remaining fall-through warnings in order to enable -Wimplicit-fallthrough for Clang.
Applied 20-22,54,120-124 to 5.11/scsi-staging, thanks.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 7 lines · Martin K. Petersen
Gustavo,
Quoted 2 lines
This series aims to fix almost all remaining fall-through warnings in order to enable -Wimplicit-fallthrough for Clang.
Applied 20-22,54,120-124 to 5.11/scsi-staging, thanks.
Awesome! :)
Thanks, Martin.
--
Gustavo
Quoted 33 lines · Kees Cook
Quoted 32 lines · Jakub Kicinski
Quoted 30 lines · On Fri, 20 Nov 2020 11:30:40 -0800 Kees Cook wrote:
Quoted 17 lines · Jakub Kicinski
Quoted 7 lines · On Fri, 20 Nov 2020 12:21:39 -0600 Gustavo A. R. Silva wrote:
This series aims to fix almost all remaining fall-through warnings in order to enable -Wimplicit-fallthrough for Clang.
In preparation to enable -Wimplicit-fallthrough for Clang, explicitly add multiple break/goto/return/fallthrough statements instead of just letting the code fall through to the next case.
Quoted 8 lines
Notice that in order to enable -Wimplicit-fallthrough for Clang, this change[1] is meant to be reverted at some point. So, this patch helps to move in that direction.
Something important to mention is that there is currently a discrepancy between GCC and Clang when dealing with switch fall-through to empty case statements or to cases that only contain a break/continue/return statement[2][3][4].
Quoted 7 lines
Are we sure we want to make this change? Was it discussed before?
Are there any bugs Clangs puritanical definition of fallthrough helped find?
IMVHO compiler warnings are supposed to warn about issues that could be bugs. Falling through to default: break; can hardly be a bug?!
It's certainly a place where the intent is not always clear. I think this makes all the cases unambiguous, and doesn't impact the machine code, since the compiler will happily optimize away any behavioral redundancy.
Quoted 5 lines
Quoted 2 lines
If none of the 140 patches here fix a real bug, and there is no change to machine code then it sounds to me like a W=2 kind of a warning.
FWIW, this series has found at least one bug so far:
https://lore.kernel.org/lkml/CAFCwf11izHF=g1mGry1fE5kvFFFrxzhPSM6qKAO8gxSp=Kr_CQ@mail.gmail.com/
This is a fallthrough to a return and not to a break. That should trigger a warning. The fallthrough to a break should not generate a warning.
The bug we're trying to fix is "missing break statement" but if the result of the bug is "we hit a break statement" then now we're just talking about style. GCC should limit itself to warning about potentially buggy code.
regards,
dan carpenter
Quoted 9 lines · Nick Desaulniers
Quoted 7 lines · Kees Cook
Quoted 2 lines · Jakub Kicinski
If none of the 140 patches here fix a real bug, and there is no change to machine code then it sounds to me like a W=2 kind of a warning.
FWIW, this series has found at least one bug so far:
https://lore.kernel.org/lkml/CAFCwf11izHF=g1mGry1fE5kvFFFrxzhPSM6qKAO8gxSp=Kr_CQ@mail.gmail.com/
Quoted 7 lines
So looks like the bulk of these are:
switch (x) {
case 0:++x; default: break; }
This should not generate a warning.
Quoted 8 lines
I have a patch that fixes those up for clang:
https://reviews.llvm.org/D91895There's 3 other cases that don't quite match between GCC and Clang I observe in the kernel:
switch (x) {
case 0:
Quoted 5 lines
++x; default: goto y; }y:;
This should generate a warning.
Quoted 7 lines
switch (x) {
case 0:++x; default: return; }
Warn for this.
Quoted 7 lines
switch (x) {
case 0:++x; default: ; }
Don't warn for this.
If adding a break statement changes the flow of the code then warn about potentially missing break statements, but if it doesn't change anything then don't warn about it.
regards,
dan carpenter
Martin K. Petersen
AppliedRe: (subset) [PATCH 000/141] Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 8 lines · Gustavo A. R. Silva
This series aims to fix almost all remaining fall-through warnings in order to enable -Wimplicit-fallthrough for Clang.
In preparation to enable -Wimplicit-fallthrough for Clang, explicitly add multiple break/goto/return/fallthrough statements instead of just letting the code fall through to the next case.
[...]
Applied to 5.11/scsi-queue, thanks!
[054/141] target: Fix fall-through warnings for Clang
https://git.kernel.org/mkp/scsi/c/492096ecfa39
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 065/141] airo: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 6 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
4 patches applied to wireless-drivers-next.git, thanks.
48264b23fade airo: Fix fall-through warnings for Clang f48d7dccb3e4 rt2x00: Fix fall-through warnings for Clang 0662fbebf4fb rtw88: Fix fall-through warnings for Clang 18572b0b5493 zd1201: Fix fall-through warnings for Clang
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/b3c0f74f5b6e6bff9f1609b310319b6fdd9ee205.1605896059.git.gustavoars@kernel.org/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Steve French
AppliedRe: [PATCH 003/141] cifs: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaMerged into cifs-2.6.git for-next
Let me know if you see any other cleanup/misc cifs.ko patches that may have gotten missed ...
Quoted 52 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break/goto statements instead of just letting the code fall through to the next case.
--- fs/cifs/inode.c | 1 + fs/cifs/sess.c | 1 + fs/cifs/smbdirect.c | 1 + 3 files changed, 3 insertions(+)fs/cifs/inode.c +1
-0@@ -771,6 +771,7 @@ cifs_get_file_info(struct file *filp)*/ rc =0 ;CIFS_I (inode)->time =0 ; + goto cgfi_exit;default : goto cgfi_exit; }fs/cifs/sess.c +1
-0@@ -812,6 +812,7 @@ cifs_select_sectype(struct TCP_Server_Info *server, enum securityEnum requested)return NTLMv2;if (global_secflags &CIFSSEC_MAY_NTLM )return NTLM ; +break ;default :break ; }fs/cifs/smbdirect.c +1
-1@@ -246,6 +246,7 @@ smbd_qp_async_error_upcall(struct ib_event *event, void *context)case IB_EVENT_CQ_ERR :case IB_EVENT_QP_FATAL :smbd_disconnect_rdma_connection (info); +break ;default :break ; --2.27.0
Signature · 3 lines
Thanks, Steve
Re: [PATCH 069/141] ath5k: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 7 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
Signed-off-by Gustavo A. R. Silva <[email protected]>Signed-off-by Kalle Valo <[email protected]>
3 patches applied to ath-next branch of ath.git, thanks.
e64fa6d92ac4 ath5k: Fix fall-through warnings for Clang e2cb11165445 carl9170: Fix fall-through warnings for Clang b6041e1a3020 wcn36xx: Fix fall-through warnings for Clang
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/e127232621c4de340509047a11d98093958303c5.1605896059.git.gustavoars@kernel.org/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [PATCH 091/141] iwlwifi: iwl-drv: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 10 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by replacing a /* fall through */ comment with the new pseudo-keyword macro fallthrough; instead of letting the code fall through to the next case.
Notice that Clang doesn't recognize /* fall through */ comments as implicit fall-through markings.
Patch applied to wireless-drivers-next.git, thanks.
10a0472d1850 iwlwifi: iwl-drv: Fix fall-through warnings for Clang
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/edd98d194bfc98b4be93a9bdc303630b719c0e66.1605896060.git.gustavoars@kernel.org/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Jürgen Groß
maintainerRe: [PATCH 058/141] xen-blkfront: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 6 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
Applied to: xen/tip.git for-linus-5.11
Juergen
Jürgen Groß
maintainerRe: [PATCH 138/141] xen/manage: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 6 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
Applied to: xen/tip.git for-linus-5.11
Juergen
Re: [PATCH 031/141] ext4: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 6 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of just letting the code fall through to the next case.
Thanks, applied.
- Ted
Re: [Bridge] [PATCH 106/141] net: bridge: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Who can take this? :)
Thanks
--
Gustavo
Quoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- net/bridge/br_input.c | 1 + 1 file changed, 1 insertion(+)net/bridge/br_input.c +1
-0@@ -148,6 +148,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skbbreak ;case BR_PKT_UNICAST : dst =br_fdb_find_rcu (br,eth_hdr (skb)->h_dest, vid); +break ;default :break ; }
Re: [PATCH 106/141] net: bridge: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 16 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- net/bridge/br_input.c | 1 + 1 file changed, 1 insertion(+)net/bridge/br_input.c +0
-0
net/bridge/br_input.c int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb · line 154
Quoted 7 lines
net/bridge/br_input.c +1
-0@@ -148,6 +148,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skbbreak ;case BR_PKT_UNICAST : dst =br_fdb_find_rcu (br,eth_hdr (skb)->h_dest, vid); +break ;default :break ; }
Somehow this hasn't hit my inbox, good thing I just got the reply and saw the patch. Anyway, thanks!
Re: [PATCH 136/141] virtio_net: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Who can take this? :)
Thanks
--
Gustavo
Quoted 16 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a goto statement instead of letting the code fall through to the next case.
--- drivers/net/virtio_net.c | 1 + 1 file changed, 1 insertion(+)drivers/net/virtio_net.c +0
-0
drivers/net/virtio_net.c static struct sk_buff *receive_small(struct net_device *dev, · line 738
Quoted 7 lines
drivers/net/virtio_net.c +1
-0@@ -732,6 +732,7 @@ static struct sk_buff *receive_small(struct net_device *dev, fallthrough;case XDP_ABORTED :trace_xdp_exception (vi->dev, xdp_prog, act); + goto err_xdp;case XDP_DROP : goto err_xdp; }
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [Bridge] [PATCH 106/141] net: bridge: Fix fall-through warnings for Clang
In reply to Nikolay AleksandrovQuoted 11 lines · Nikolay Aleksandrov
Quoted 10 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- net/bridge/br_input.c | 1 + 1 file changed, 1 insertion(+)
Quoted 16 lines
net/bridge/br_input.c int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb · line 154
Quoted 13 lines
net/bridge/br_input.c +1
-0@@ -148,6 +148,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skbbreak ;case BR_PKT_UNICAST : dst =br_fdb_find_rcu (br,eth_hdr (skb)->h_dest, vid); +break ;default :break ; }Somehow this hasn't hit my inbox, good thing I just got the reply and saw the patch. Anyway, thanks!
A lot of e-mails have been bouncing, recently. :/
I think I'll resend all the net patches in this series.
Quoted 1 line
Thanks!
--
Gustavo
Re: [PATCH 104/141] mtd: rawnand: stm32_fmc2: Fix fall-through warnings for Clang
In reply to Miquel RaynalHi Miquel,
Quoted 15 lines · Miquel Raynal
Hi Gustavo,
"Gustavo A. R. Silva" <[email protected]> wrote on Fri, 20 Nov 2020 12:37:48 -0600:
Quoted 10 lines
In preparation to enable -Wimplicit-fallthrough for Clang, fix a couple of warnings by explicitly adding a couple of fallthrough pseudo-keywords instead of letting the code fall through to the next case.
--- drivers/mtd/nand/raw/stm32_fmc2_nand.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 14 lines
drivers/mtd/nand/raw/stm32_fmc2_nand.c static int stm32_fmc2_nfc_ham_correct(struct nand_chip *chip, u8 *dat, · line 534
Quoted 9 lines
drivers/mtd/nand/raw/stm32_fmc2_nand.c +1
-0@@ -531,6 +531,7 @@ static int stm32_fmc2_nfc_ham_correct(struct nand_chip *chip, u8 *dat,switch (b %4 ) {case 2 : bit_position += shifting; + fallthrough;In patch 100, 101, 102, 103 you 'break' in this case (when the statement falls into the empty following statement which itself breaks). Please make it consistent and use break here, below, and in patch 132.
I'll address this and send separate patches.
Quoted 1 line
LGTM otherwise.
Thanks!
--
Gustavo
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 042/141] net: 3c509: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
It's been more than 3 months; who can take this, please? :)
Thanks
--
Gustavo
Quoted 25 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of just letting the code fall through to the next case.
--- drivers/net/ethernet/3com/3c509.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/3com/3c509.c +1
-0@@ -1052,6 +1052,7 @@ el3_netdev_get_ecmd(struct net_device *dev, struct ethtool_link_ksettings *cmd)break ;case 3 : cmd->base.port =PORT_BNC ; +break ;default :break ; }Signature · 1 line
2.27.0
Re: [PATCH 043/141] net: cassini: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
It's been more than 3 months; who can take this, please? :)
Thanks
--
Gustavo
Quoted 25 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of just letting the code fall through to the next case.
--- drivers/net/ethernet/sun/cassini.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/sun/cassini.c +1
-0@@ -1599,6 +1599,7 @@ static inline int cas_mdio_link_not_up(struct cas *cp)cas_phy_write (cp,MII_BMCR , val);break ; } +break ;default :break ; }Signature · 1 line
2.27.0
Re: [PATCH 045/141] net: mscc: ocelot: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
It's been more than 3 months; who can take this, please? :)
Thanks
--
Gustavo
Quoted 25 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of just letting the code fall through to the next case.
--- drivers/net/ethernet/mscc/ocelot_vcap.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/mscc/ocelot_vcap.c +1
-0@@ -761,6 +761,7 @@ static void is1_entry_set(struct ocelot *ocelot, int ix,vcap_key_bytes_set (vcap, &data,VCAP_IS1_HK_ETYPE , etype.value, etype.mask); } +break ; }default :break ;Signature · 1 line
2.27.0
Re: [PATCH 076/141] decnet: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
It's been more than 3 months; who can take this, please? :)
Thanks
--
Gustavo
Quoted 26 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- net/decnet/dn_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/decnet/dn_route.c +1
-1@@ -1407,7 +1407,7 @@ static int dn_route_input_slow(struct sk_buff *skb) flags |=RTCF_DOREDIRECT ; local_src =DN_FIB_RES_PREFSRC (res); - +break ;case RTN_BLACKHOLE :case RTN_UNREACHABLE :break ;Signature · 1 line
2.27.0
Re: [PATCH 105/141] net: ax25: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
It's been more than 3 months; who can take this, please? :)
Thanks
--
Gustavo
Quoted 25 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- net/ax25/af_ax25.c | 1 + 1 file changed, 1 insertion(+)net/ax25/af_ax25.c +1
-0@@ -850,6 +850,7 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol,case AX25_P_ROSE :if (ax25_protocol_is_registered (AX25_P_ROSE ))return -ESOCKTNOSUPPORT ; +break ;#endif default :break ;Signature · 1 line
2.27.0
Re: [PATCH 106/141] net: bridge: Fix fall-through warnings for Clang
In reply to Nikolay AleksandrovHi all,
It's been more than 3 months; who can take this, please? :)
Thanks
--
Gustavo
Quoted 30 lines · Nikolay Aleksandrov
Quoted 16 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- net/bridge/br_input.c | 1 + 1 file changed, 1 insertion(+)net/bridge/br_input.c +0
-0net/bridge/br_input.c int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb · line 154
Quoted 7 lines
net/bridge/br_input.c +1
-0@@ -148,6 +148,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skbbreak ;case BR_PKT_UNICAST : dst =br_fdb_find_rcu (br,eth_hdr (skb)->h_dest, vid); +break ;default :break ; }Somehow this hasn't hit my inbox, good thing I just got the reply and saw the patch. Anyway, thanks!
Re: [PATCH 107/141] net: core: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
It's been more than 3 months; who can take this, please? :)
Thanks
--
Gustavo
Quoted 25 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- net/core/dev.c | 1 + 1 file changed, 1 insertion(+)net/core/dev.c +1
-0@@ -5214,6 +5214,7 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc, goto another_round;case RX_HANDLER_EXACT : deliver_exact = true; +break ;case RX_HANDLER_PASS :break ;default :Signature · 1 line
2.27.0
Re: [PATCH 111/141] net: plip: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
It's been more than 3 months; who can take this, please? :)
Thanks
--
Gustavo
Quoted 33 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of letting the code fall through to the next case.
--- drivers/net/plip/plip.c | 2 ++ 1 file changed, 2 insertions(+)drivers/net/plip/plip.c +2
-0@@ -516,6 +516,7 @@ plip_receive(unsigned short nibble_timeout, struct net_device *dev, *data_p |= (c0 <<1 ) &0xf0 ;write_data (dev,0x00 );/* send ACK */ *ns_p =PLIP_NB_BEGIN ; +break ;case PLIP_NB_2 :break ; }@@ -808,6 +809,7 @@ plip_send_packet(struct net_device *dev, struct net_local *nl,return HS_TIMEOUT ; } } +break ;case PLIP_PK_LENGTH_LSB : if (plip_send(nibble_timeout, dev,Signature · 1 line
2.27.0
Re: [PATCH 112/141] net: rose: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
It's been more than 3 months; who can take this, please? :)
Thanks
--
Gustavo
Quoted 33 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of letting the code fall through to the next case.
--- net/rose/rose_route.c | 2 ++ 1 file changed, 2 insertions(+)net/rose/rose_route.c +2
-0@@ -347,6 +347,7 @@ static int rose_del_node(struct rose_route_struct *rose_route,case 1 : rose_node->neighbour[1 ] = rose_node->neighbour[2 ]; +break ;case 2 :break ; }@@ -508,6 +509,7 @@ void rose_rt_device_down(struct net_device *dev) fallthrough;case 1 : t->neighbour[1 ] = t->neighbour[2 ]; +break ;case 2 :break ; }Signature · 1 line
2.27.0
Re: [PATCH 045/141] net: mscc: ocelot: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi Gustavo,
Quoted 16 lines · Gustavo A. R. Silva
Hi all,
It's been more than 3 months; who can take this, please? :)
Thanks
--
GustavoQuoted 7 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of just letting the code fall through to the next case.
---
You'd obviously need to resend. But when you do please add my:
And by the way, I think the netdev maintainers might want to take the patches on network drivers to avoid conflicts, but on the other hand they might not be too keen on cherry-picking bits and pieces of your 141 patch series. Would you mind creating a bundle of patches only for netdev? I see there's definitely more than just one patch, they would certainly get in a lot quicker that way.
Re: [PATCH 057/141] watchdog: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
It's been more than 3 months; who can take this, please? :)
Thanks
--
Gustavo
Quoted 25 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a fallthrough pseudo-keyword instead of letting the code fall through to the next case.
--- drivers/watchdog/machzwd.c | 1 + 1 file changed, 1 insertion(+)drivers/watchdog/machzwd.c +1
-0@@ -174,6 +174,7 @@ static inline void zf_set_timer(unsigned short new, unsigned char n) fallthrough;case WD2 :zf_writeb (COUNTER_2 , new >0xff ?0xff : new); + fallthrough;default :return ; }Signature · 1 line
2.27.0
Guenter Roeck
maintainerRe: [PATCH 057/141] watchdog: Fix fall-through warnings for Clang
Quoted 4 lines · Gustavo A. R. Silva
Hi all,
It's been more than 3 months; who can take this, please? :)
I am not in favor of cosmetic patches for old drivers, and I am not going to provide tags for them anymore. The driver should be converted to use the watchdog core, or it should be dropped.
Guenter
Re: [PATCH 057/141] watchdog: Fix fall-through warnings for Clang
Quoted 7 lines · Guenter Roeck
Quoted 4 lines · Gustavo A. R. Silva
Hi all,
It's been more than 3 months; who can take this, please? :)
I am not in favor of cosmetic patches for old drivers,
Me either. However, this is not a cosmetic patch[1].
Quoted 3 lines
and I am not going to provide tags for them anymore. The driver should be converted to use the watchdog core, or it should be dropped.
Is it OK with you if I carry this in my tree for a future pull-request to Linus?
Thanks!
--
Gustavo
Re: [PATCH 045/141] net: mscc: ocelot: Fix fall-through warnings for Clang
In reply to Vladimir OlteanHi Vladimir,
Quoted 22 lines · Vladimir Oltean
Hi Gustavo,
Quoted 16 lines · Gustavo A. R. Silva
Hi all,
It's been more than 3 months; who can take this, please? :)
Thanks
--
GustavoQuoted 7 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of just letting the code fall through to the next case.
---
You'd obviously need to resend. But when you do please add my:
Quoted 8 lines
Reviewed-by Vladimir Oltean <[email protected]>And by the way, I think the netdev maintainers might want to take the patches on network drivers to avoid conflicts, but on the other hand they might not be too keen on cherry-picking bits and pieces of your 141 patch series. Would you mind creating a bundle of patches only for netdev? I see there's definitely more than just one patch, they would certainly get in a lot quicker that way.
Thanks for your feedback. I already sent those patches again. I hope they are applied this time. :)
--
Gustavo
Re: [PATCH 092/141] libata: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- drivers/ata/libata-eh.c | 1 + 1 file changed, 1 insertion(+)drivers/ata/libata-eh.c +1
-0@@ -2613,6 +2613,7 @@ int ata_eh_reset(struct ata_link *link, int classify,switch (tmp) {case -EAGAIN : rc = -EAGAIN ; +break ;case 0 :break ;default :
Re: [PATCH 077/141] dm raid: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- drivers/md/dm-raid.c | 1 + 1 file changed, 1 insertion(+)drivers/md/dm-raid.c +1
-0@@ -1854,6 +1854,7 @@ static int rs_check_takeover(struct raid_set *rs) ((mddev->layout ==ALGORITHM_PARITY_N && mddev->new_layout ==ALGORITHM_PARITY_N ) || __within_range(mddev->new_layout, ALGORITHM_LEFT_ASYMMETRIC, ALGORITHM_RIGHT_SYMMETRIC))) return 0; +break ;default :break ;
Re: [PATCH 070/141] atm: fore200e: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 22 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a fallthrough pseudo-keyword.
--- drivers/atm/fore200e.c | 1 + 1 file changed, 1 insertion(+)drivers/atm/fore200e.c +1
-0@@ -423,6 +423,7 @@ fore200e_shutdown(struct fore200e* fore200e)/* XXX shouldn't we *start* by deregistering the device? */ atm_dev_deregister (fore200e->atm_dev); + fallthrough;case FORE200E_STATE_BLANK :/* nothing to do for that state */ break ;
Re: [PATCH 061/141] tee: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 20 lines · Gustavo A. R. Silva
Quoted 7 lines · Jens Wiklander
Quoted 5 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
Quoted 7 lines
Quoted 5 lines
--- drivers/tee/tee_core.c | 1 + 1 file changed, 1 insertion(+)Acked-by Jens Wiklander <[email protected]>Thanks, Jens.
--
Gustavo
Re: [PATCH 051/141] reiserfs: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- fs/reiserfs/namei.c | 1 + 1 file changed, 1 insertion(+)fs/reiserfs/namei.c +1
-0@@ -132,6 +132,7 @@ int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,return IO_ERROR ; }PATH_LAST_POSITION (path)--; +break ;case ITEM_FOUND :break ;
Jens Axboe
maintainerRe: [PATCH 092/141] libata: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 3 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Applied for 5.13.
Signature · 1 line
Jens Axboe
Re: [PATCH 038/141] isofs: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of just letting the code fall through to the next case.
--- fs/isofs/rock.c | 1 + 1 file changed, 1 insertion(+)fs/isofs/rock.c +1
-0@@ -767,6 +767,7 @@ static int rock_ridge_symlink_readpage(struct file *file, struct page *page) rs.cont_extent =isonum_733 (rr->u.CE.extent); rs.cont_offset =isonum_733 (rr->u.CE.offset); rs.cont_size =isonum_733 (rr->u.CE.size); +break ;default :break ; }
Re: [PATCH 032/141] floppy: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a fallthrough pseudo-keyword in places where the code is intended to fall through to the next case.
--- drivers/block/floppy.c | 1 + 1 file changed, 1 insertion(+)drivers/block/floppy.c +1
-0@@ -2124,6 +2124,7 @@ static void format_interrupt(void)switch (interpret_errors ()) {case 1 : cont->error (); + fallthrough;case 2 :break ;case 0 :
Re: [PATCH 027/141] drbd: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 37 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a couple of warnings by explicitly adding a break statement instead of just letting the code fall through to the next, and by adding a fallthrough pseudo-keyword in places whre the code is intended to fall through.
--- drivers/block/drbd/drbd_receiver.c | 1 + drivers/block/drbd/drbd_req.c | 1 + 2 files changed, 2 insertions(+)drivers/block/drbd/drbd_receiver.c +1
-0@@ -5863,6 +5863,7 @@ static int got_NegRSDReply(struct drbd_connection *connection, struct packet_infswitch (pi->cmd) {case P_NEG_RS_DREPLY :drbd_rs_failed_io (device, sector, size); +break ;case P_RS_CANCEL :break ;default :drivers/block/drbd/drbd_req.c +1
-0@@ -750,6 +750,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what,case WRITE_ACKED_BY_PEER_AND_SIS : req->rq_state |=RQ_NET_SIS ; + fallthrough;case WRITE_ACKED_BY_PEER :/* Normal operation protocol C: successfully written on peer. * During resync, even in protocol != C,
Re: [PATCH 016/141] nfsd: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 50 lines · Gustavo A. R. Silva
Quoted 36 lines · Chuck Lever
Quoted 36 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding a couple of break statements instead of just letting the code fall through to the next case.
---
fs/nfsd/nfs4state.c| 1 +fs/nfsd/nfsctl.c| 1 +2 files changed, 2 insertions(+)fs/nfsd/nfs4state.c +1
-0@@ -3113,6 +3113,7 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, goto out_nolock; } new->cl_mach_cred = true; +break ;case SP4_NONE :break ;default :/* checked by xdr code */ fs/nfsd/nfsctl.c +1
-0@@ -1165,6 +1165,7 @@ static struct inode *nfsd_get_inode(struct super_block *sb, umode_t mode) inode->i_fop = &simple_dir_operations; inode->i_op = &simple_dir_inode_operations;inc_nlink (inode); +break ;Quoted 8 lines
Quoted 6 lines
fs/nfsd/nfsctl.c +0
-0default :break ; }Signature · 1 line
2.27.0Acked-by Chuck Lever <[email protected]>Thanks, Chuck.
--
Gustavo
Re: [PATCH 010/141] ima: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 44 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of just letting the code fall through to the next case.
--- security/integrity/ima/ima_main.c | 1 + security/integrity/ima/ima_policy.c | 2 ++ 2 files changed, 3 insertions(+)security/integrity/ima/ima_main.c +1
-0@@ -743,6 +743,7 @@ int ima_load_data(enum kernel_load_data_id id, bool contents)pr_err ("impossible to appraise a module without a file descriptor. sig_enforce kernel parameter might help\n" );return -EACCES ;/* INTEGRITY_UNKNOWN */ } +break ;default :break ; }security/integrity/ima/ima_policy.c +2
-0@@ -566,6 +566,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode, rc =ima_filter_rule_match (secid, rule->lsm[i].type, Audit_equal, rule->lsm[i].rule); +break ;default :break ; }@@ -802,6 +803,7 @@ void __init ima_init_policy(void)add_rules (default_measurement_rules,ARRAY_SIZE (default_measurement_rules),IMA_DEFAULT_POLICY ); +break ;default :break ; }
Re: [PATCH 006/141] gfs2: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 44 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple goto statements instead of just letting the code fall through to the next case.
--- fs/gfs2/inode.c | 2 ++ fs/gfs2/recovery.c | 1 + 2 files changed, 3 insertions(+)fs/gfs2/inode.c +2
-0@@ -960,6 +960,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,break ;case 0 : error = -EEXIST ; + goto out_gunlock;default : goto out_gunlock; }@@ -1500,6 +1501,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,break ;case 0 : error = -EEXIST ; + goto out_gunlock;default : goto out_gunlock; }fs/gfs2/recovery.c +1
-0@@ -437,6 +437,7 @@ void gfs2_recover_func(struct work_struct *work)case GLR_TRYFAILED :fs_info (sdp,"jid=%u: Busy\n" , jd->jd_jid); error =0 ; + goto fail;default : goto fail;
Re: [PATCH 092/141] libata: Fix fall-through warnings for Clang
In reply to Jens AxboeQuoted 7 lines · Jens Axboe
Quoted 3 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Applied for 5.13.
Thanks, Jens.
--
Gustavo
Jens Axboe
maintainerRe: [PATCH 032/141] floppy: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 19 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Thanks
--
GustavoQuoted 10 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a fallthrough pseudo-keyword in places where the code is intended to fall through to the next case.
--- drivers/block/floppy.c | 1 + 1 file changed, 1 insertion(+)
Quoted 12 lines
drivers/block/floppy.c static void format_interrupt(void) · line 2130
Quoted 12 lines
drivers/block/floppy.c +1
-0@@ -2124,6 +2124,7 @@ static void format_interrupt(void)switch (interpret_errors ()) {case 1 : cont->error (); + fallthrough;case 2 :break ;case 0 :
I wonder about the consistency of the patches. The one I just applied for libata adds a break, this one annotates fallthrough. But the cases are really 100% the same. Why aren't the changes consistent? Both are obviously fine, but for identical cases it seems odd that they differ.
IMHO, adding a break makes more sense. Annotate the fallthrough if the two cases share work that needs to be done, as then that solution makes sense.
Signature · 1 line
Jens Axboe
Denis Efremov
maintainerRe: [PATCH 032/141] floppy: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi,
Sorry, this was missed somehow.
I would rewrite it to something more simple instead of adding fallthrough.
What about?
drivers/block/floppy.c +4 -2
@@ -2123,12 +2123,14 @@ static void set_floppy(int drive)static void format_interrupt (void ) {switch (interpret_errors ()) { +case 0 : + cont->done (1 ); +break ;case 1 : cont->error (); +break ;case 2 :break ; -case 0 : - cont->done (1 ); } cont->redo (); }
Quoted 32 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Thanks
--
GustavoQuoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a fallthrough pseudo-keyword in places where the code is intended to fall through to the next case.
--- drivers/block/floppy.c | 1 + 1 file changed, 1 insertion(+)drivers/block/floppy.c +1
-0@@ -2124,6 +2124,7 @@ static void format_interrupt(void)switch (interpret_errors ()) {case 1 : cont->error (); + fallthrough;case 2 :break ;case 0 :
Re: [PATCH 071/141] braille_console: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
Friendly ping: who can take this, please?
Thanks
--
Gustavo
Quoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- drivers/accessibility/braille/braille_console.c | 1 + 1 file changed, 1 insertion(+)drivers/accessibility/braille/braille_console.c +1
-0@@ -246,6 +246,7 @@ static int keyboard_notifier_call(struct notifier_block *blk,beep (440 ); } } +break ;case KBD_UNBOUND_KEYCODE :case KBD_UNICODE :case KBD_KEYSYM :
Re: [PATCH 032/141] floppy: Fix fall-through warnings for Clang
In reply to Jens AxboeQuoted 19 lines · Jens Axboe
Quoted 13 lines
drivers/block/floppy.c static void format_interrupt(void) · line 2130
Quoted 13 lines
drivers/block/floppy.c +1
-0@@ -2124,6 +2124,7 @@ static void format_interrupt(void)switch (interpret_errors ()) {case 1 : cont->error (); + fallthrough;case 2 :break ;case 0 :I wonder about the consistency of the patches. The one I just applied for libata adds a break, this one annotates fallthrough. But the cases are really 100% the same. Why aren't the changes consistent? Both are obviously fine, but for identical cases it seems odd that they differ.
Quoted 4 lines
IMHO, adding a break makes more sense. Annotate the fallthrough if the two cases share work that needs to be done, as then that solution makes sense.
Yeah; I'll resend this with a break, instead.
Thanks for the feedback.
--
Gustavo
Re: [PATCH 006/141] gfs2: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaAm Di., 20. Apr. 2021 um 22:29 Uhr schrieb Gustavo A. R. Silva <[email protected]>:
Quoted 1 line
Friendly ping: who can take this, please?
Oops, that got lost. I've added it to for-next now.
Thanks,
Andreas
Re: [PATCH 016/141] nfsd: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 7 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Hum. I thought this was going through another tree. I can take it for the second v5.13 NFSD PR.
Quoted 4 lines
Thanks
--
Gustavo
Quoted 50 lines
Quoted 49 lines · Gustavo A. R. Silva
Quoted 36 lines · Chuck Lever
Quoted 36 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding a couple of break statements instead of just letting the code fall through to the next case.
---
fs/nfsd/nfs4state.c| 1 +fs/nfsd/nfsctl.c| 1 +2 files changed, 2 insertions(+)fs/nfsd/nfs4state.c +1
-0@@ -3113,6 +3113,7 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, goto out_nolock; } new->cl_mach_cred = true; +break ;case SP4_NONE :break ;default :/* checked by xdr code */ fs/nfsd/nfsctl.c +1
-0@@ -1165,6 +1165,7 @@ static struct inode *nfsd_get_inode(struct super_block *sb, umode_t mode) inode->i_fop = &simple_dir_operations; inode->i_op = &simple_dir_inode_operations;inc_nlink (inode); +break ;Quoted 8 lines
Quoted 6 lines
fs/nfsd/nfsctl.c +0
-0default :break ; }Signature · 1 line
2.27.0Acked-by Chuck Lever <[email protected]>Thanks, Chuck.
--
Gustavo
--
Chuck Lever
Re: [PATCH 027/141] drbd: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 3 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Applied, thanks.
Signature · 1 line
Jens Axboe
Mimi Zohar
maintainerRe: [PATCH 010/141] ima: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi Gustavo,
Quoted 3 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Thank you for the reminder.
Quoted 8 lines · Gustavo A. R. Silva
Quoted 6 lines
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of just letting the code fall through to the next case.
Applied togit://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git
next-integrity
thanks,
Mimi
Mike Snitzer
AppliedRe: [PATCH 077/141] dm raid: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaQuoted 29 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Thanks
--
GustavoQuoted 20 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- drivers/md/dm-raid.c | 1 + 1 file changed, 1 insertion(+)drivers/md/dm-raid.c +1
-0@@ -1854,6 +1854,7 @@ static int rs_check_takeover(struct raid_set *rs) ((mddev->layout ==ALGORITHM_PARITY_N && mddev->new_layout ==ALGORITHM_PARITY_N ) || __within_range(mddev->new_layout, ALGORITHM_LEFT_ASYMMETRIC, ALGORITHM_RIGHT_SYMMETRIC))) return 0; +break ;
Quoted 4 lines
drivers/md/dm-raid.c static int rs_check_takeover(struct raid_set *rs) · line 1860
Quoted 3 lines
drivers/md/dm-raid.c +0
-0default :break ;
I've picked it up for 5.13, thanks.
Mike
Re: [PATCH 077/141] dm raid: Fix fall-through warnings for Clang
Quoted 1 line · Mike Snitzer
I've picked it up for 5.13, thanks.
Thanks, Mike.
--
Gustavo
Re: [PATCH 010/141] ima: Fix fall-through warnings for Clang
In reply to Mimi ZoharQuoted 3 lines · Mimi Zohar
Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git
next-integrity
Thanks, Mimi.
--
Gustavo
Re: [PATCH 027/141] drbd: Fix fall-through warnings for Clang
In reply to Jens AxboeQuoted 1 line · Jens Axboe
Applied, thanks.
Awesome. :)
Thanks
--
Gustavo
Re: [PATCH 061/141] tee: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi,
Quoted 24 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Thanks
--
GustavoQuoted 15 lines · Gustavo A. R. Silva
Quoted 14 lines · Jens Wiklander
Quoted 10 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- drivers/tee/tee_core.c | 1 + 1 file changed, 1 insertion(+)Acked-by Jens Wiklander <[email protected]>
I've added this to my -next[1] branch for v5.14.
Thanks
--
Gustavo
[1] https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/log/?h=for-next/kspp
Re: [PATCH 070/141] atm: fore200e: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
I've added this to my -next[1] branch for v5.14.
Thanks
--
Gustavo
[1] https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/log/?h=for-next/kspp
Quoted 31 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Thanks
--
GustavoQuoted 22 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a fallthrough pseudo-keyword.
--- drivers/atm/fore200e.c | 1 + 1 file changed, 1 insertion(+)drivers/atm/fore200e.c +1
-0@@ -423,6 +423,7 @@ fore200e_shutdown(struct fore200e* fore200e)/* XXX shouldn't we *start* by deregistering the device? */ atm_dev_deregister (fore200e->atm_dev); + fallthrough;case FORE200E_STATE_BLANK :/* nothing to do for that state */ break ;
Re: [PATCH 057/141] watchdog: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi all,
I'm taking this in my -next[1] branch for v5.14.
Thanks
--
Gustavo
[1] https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/log/?h=for-next/kspp
Quoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a fallthrough pseudo-keyword instead of letting the code fall through to the next case.
--- drivers/watchdog/machzwd.c | 1 + 1 file changed, 1 insertion(+)drivers/watchdog/machzwd.c +1
-0@@ -174,6 +174,7 @@ static inline void zf_set_timer(unsigned short new, unsigned char n) fallthrough;case WD2 :zf_writeb (COUNTER_2 , new >0xff ?0xff : new); + fallthrough;default :return ; }
Re: [PATCH 051/141] reiserfs: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi,
I'm taking this in my -next[1] branch for v5.14.
Thanks
--
Gustavo
[1] https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/log/?h=for-next/kspp
Quoted 32 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Thanks
--
GustavoQuoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- fs/reiserfs/namei.c | 1 + 1 file changed, 1 insertion(+)fs/reiserfs/namei.c +1
-0@@ -132,6 +132,7 @@ int search_by_entry_key(struct super_block *sb, const struct cpu_key *key,return IO_ERROR ; }PATH_LAST_POSITION (path)--; +break ;case ITEM_FOUND :break ;
Re: [PATCH 071/141] braille_console: Fix fall-through warnings for Clang
In reply to Gustavo A. R. SilvaHi,
I'm taking this in my -next[1] branch for v5.14.
Thanks
--
Gustavo
[1] https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/log/?h=for-next/kspp
Quoted 32 lines · Gustavo A. R. Silva
Hi all,
Friendly ping: who can take this, please?
Thanks
--
GustavoQuoted 23 lines · Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case.
--- drivers/accessibility/braille/braille_console.c | 1 + 1 file changed, 1 insertion(+)drivers/accessibility/braille/braille_console.c +1
-0@@ -246,6 +246,7 @@ static int keyboard_notifier_call(struct notifier_block *blk,beep (440 ); } } +break ;case KBD_UNBOUND_KEYCODE :case KBD_UNICODE :case KBD_KEYSYM :