* [PATCH] drbd_receiver: mark expected switch fall-throughs
@ 2019-02-12 21:28 Gustavo A. R. Silva
2019-02-12 21:36 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2019-02-12 21:28 UTC (permalink / raw)
To: Philipp Reisner, Lars Ellenberg, Jens Axboe
Cc: drbd-dev, linux-block, linux-kernel, Gustavo A. R. Silva, Kees Cook
In preparation to enabling -Wimplicit-fallthrough, mark switch
cases where we are expecting to fall through.
This patch fixes the following warnings:
drivers/block/drbd/drbd_receiver.c: In function ‘drbd_asb_recover_0p’:
drivers/block/drbd/drbd_receiver.c:3093:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
if (self == 1 && peer == 0) {
^
drivers/block/drbd/drbd_receiver.c:3098:2: note: here
case ASB_DISCARD_OLDER_PRI:
^~~~
drivers/block/drbd/drbd_receiver.c:3120:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
if (after_sb_0p == ASB_DISCARD_ZERO_CHG)
^
drivers/block/drbd/drbd_receiver.c:3123:2: note: here
case ASB_DISCARD_LEAST_CHG:
^~~~
Warning level 3 was used: -Wimplicit-fallthrough=3
Notice that in some cases, the code comment is modified in
accordance with what GCC is expecting to find.
This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/block/drbd/drbd_receiver.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index c7ad88d91a09..78bb763a367d 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -3094,7 +3094,7 @@ static int drbd_asb_recover_0p(struct drbd_peer_device *peer_device) __must_hold
rv = 1;
break;
}
- /* Else fall through to one of the other strategies... */
+ /* Else fall through - to one of the other strategies... */
case ASB_DISCARD_OLDER_PRI:
if (self == 0 && peer == 1) {
rv = 1;
@@ -3119,7 +3119,7 @@ static int drbd_asb_recover_0p(struct drbd_peer_device *peer_device) __must_hold
}
if (after_sb_0p == ASB_DISCARD_ZERO_CHG)
break;
- /* else: fall through */
+ /* Else fall through */
case ASB_DISCARD_LEAST_CHG:
if (ch_self < ch_peer)
rv = -1;
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drbd_receiver: mark expected switch fall-throughs
2019-02-12 21:28 [PATCH] drbd_receiver: mark expected switch fall-throughs Gustavo A. R. Silva
@ 2019-02-12 21:36 ` Jens Axboe
2019-02-15 0:29 ` Gustavo A. R. Silva
0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2019-02-12 21:36 UTC (permalink / raw)
To: Gustavo A. R. Silva, Philipp Reisner, Lars Ellenberg
Cc: drbd-dev, linux-block, linux-kernel, Kees Cook
On 2/12/19 2:28 PM, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch
> cases where we are expecting to fall through.
>
> This patch fixes the following warnings:
>
> drivers/block/drbd/drbd_receiver.c: In function ‘drbd_asb_recover_0p’:
> drivers/block/drbd/drbd_receiver.c:3093:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
> if (self == 1 && peer == 0) {
> ^
> drivers/block/drbd/drbd_receiver.c:3098:2: note: here
> case ASB_DISCARD_OLDER_PRI:
> ^~~~
> drivers/block/drbd/drbd_receiver.c:3120:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
> if (after_sb_0p == ASB_DISCARD_ZERO_CHG)
> ^
> drivers/block/drbd/drbd_receiver.c:3123:2: note: here
> case ASB_DISCARD_LEAST_CHG:
> ^~~~
>
> Warning level 3 was used: -Wimplicit-fallthrough=3
>
> Notice that in some cases, the code comment is modified in
> accordance with what GCC is expecting to find.
>
> This patch is part of the ongoing efforts to enable
> -Wimplicit-fallthrough.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/block/drbd/drbd_receiver.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
> index c7ad88d91a09..78bb763a367d 100644
> --- a/drivers/block/drbd/drbd_receiver.c
> +++ b/drivers/block/drbd/drbd_receiver.c
> @@ -3094,7 +3094,7 @@ static int drbd_asb_recover_0p(struct drbd_peer_device *peer_device) __must_hold
> rv = 1;
> break;
> }
> - /* Else fall through to one of the other strategies... */
> + /* Else fall through - to one of the other strategies... */
> case ASB_DISCARD_OLDER_PRI:
> if (self == 0 && peer == 1) {
> rv = 1;
> @@ -3119,7 +3119,7 @@ static int drbd_asb_recover_0p(struct drbd_peer_device *peer_device) __must_hold
> }
> if (after_sb_0p == ASB_DISCARD_ZERO_CHG)
> break;
> - /* else: fall through */
> + /* Else fall through */
This is getting really silly, as these two hunks both aptly demonstrate. Can
we please inject some sanity into this fall through witch hunt?
The last hunk is updating ANOTHER patch that also attempted to silence this
stuff.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drbd_receiver: mark expected switch fall-throughs
2019-02-12 21:36 ` Jens Axboe
@ 2019-02-15 0:29 ` Gustavo A. R. Silva
0 siblings, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2019-02-15 0:29 UTC (permalink / raw)
To: Jens Axboe, Philipp Reisner, Lars Ellenberg
Cc: drbd-dev, linux-block, linux-kernel, Kees Cook
On 2/12/19 3:36 PM, Jens Axboe wrote:
> On 2/12/19 2:28 PM, Gustavo A. R. Silva wrote:
>> In preparation to enabling -Wimplicit-fallthrough, mark switch
>> cases where we are expecting to fall through.
>>
>> This patch fixes the following warnings:
>>
>> drivers/block/drbd/drbd_receiver.c: In function ‘drbd_asb_recover_0p’:
>> drivers/block/drbd/drbd_receiver.c:3093:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>> if (self == 1 && peer == 0) {
>> ^
>> drivers/block/drbd/drbd_receiver.c:3098:2: note: here
>> case ASB_DISCARD_OLDER_PRI:
>> ^~~~
>> drivers/block/drbd/drbd_receiver.c:3120:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
>> if (after_sb_0p == ASB_DISCARD_ZERO_CHG)
>> ^
>> drivers/block/drbd/drbd_receiver.c:3123:2: note: here
>> case ASB_DISCARD_LEAST_CHG:
>> ^~~~
>>
>> Warning level 3 was used: -Wimplicit-fallthrough=3
>>
>> Notice that in some cases, the code comment is modified in
>> accordance with what GCC is expecting to find.
>>
>> This patch is part of the ongoing efforts to enable
>> -Wimplicit-fallthrough.
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>> drivers/block/drbd/drbd_receiver.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
>> index c7ad88d91a09..78bb763a367d 100644
>> --- a/drivers/block/drbd/drbd_receiver.c
>> +++ b/drivers/block/drbd/drbd_receiver.c
>> @@ -3094,7 +3094,7 @@ static int drbd_asb_recover_0p(struct drbd_peer_device *peer_device) __must_hold
>> rv = 1;
>> break;
>> }
>> - /* Else fall through to one of the other strategies... */
>> + /* Else fall through - to one of the other strategies... */
>> case ASB_DISCARD_OLDER_PRI:
>> if (self == 0 && peer == 1) {
>> rv = 1;
>> @@ -3119,7 +3119,7 @@ static int drbd_asb_recover_0p(struct drbd_peer_device *peer_device) __must_hold
>> }
>> if (after_sb_0p == ASB_DISCARD_ZERO_CHG)
>> break;
>> - /* else: fall through */
>> + /* Else fall through */
>
> This is getting really silly, as these two hunks both aptly demonstrate. Can
> we please inject some sanity into this fall through witch hunt?
>
No witch hunt here. This work has proved to be very valuable. I've fixed years-old
bugs thanks to this effort.
> The last hunk is updating ANOTHER patch that also attempted to silence this
> stuff.
>
Yeah. Sorry about that.
Previously, I was using level 2: -Wimplicit-fallthrough=2, but this time I'm
using level 3: -Wimplicit-fallthrough=3, which is stricter and maps to -Wextra.
Thanks
--
Gustavo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-15 0:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12 21:28 [PATCH] drbd_receiver: mark expected switch fall-throughs Gustavo A. R. Silva
2019-02-12 21:36 ` Jens Axboe
2019-02-15 0:29 ` Gustavo A. R. Silva
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.