lkml.org 
[lkml]   [2019]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH net-next] amd-xgbe: Mark expected switch fall-throughs
From
Date
Hi,

On 4/25/19 8:12 AM, Lendacky, Thomas wrote:
[..]
>> ^~~~
>>
>> Warning level 3 was used: -Wimplicit-fallthrough=3
>>
>> Notice that, in this particular case, the code comments are 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/net/ethernet/amd/xgbe/xgbe-drv.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
>> index 0cc911f928b1..3dd0cecddba8 100644
>> --- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
>> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
>> @@ -1612,7 +1612,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
>> /* PTP v2, UDP, any kind of event packet */
>> case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
>> XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSVER2ENA, 1);
>> - /* PTP v1, UDP, any kind of event packet */
>> + /* Fall through - to PTP v1, UDP, any kind of event packet */
>
> If the compiler doesn't have a problem with adding just an indented
> "Fall through" comment and leaving the original comment in place, I would
> prefer that. It seems clearer to me.
>

This is the other alternative:

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 0cc911f928b1..f913bf404baa 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -1613,6 +1613,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSVER2ENA, 1);
/* PTP v1, UDP, any kind of event packet */
+ /* Fall through */
case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV4ENA, 1);
XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV6ENA, 1);
@@ -1624,6 +1625,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSVER2ENA, 1);
/* PTP v1, UDP, Sync packet */
+ /* Fall through */
case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV4ENA, 1);
XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV6ENA, 1);
@@ -1635,6 +1637,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSVER2ENA, 1);
/* PTP v1, UDP, Delay_req packet */
+ /* Fall through */
case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV4ENA, 1);
XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV6ENA, 1);

The thing is that the fall-through comments have to be placed at the
very bottom of each case.

Which do you prefer?

Thanks
--
Gustavo

> Thanks,
> Tom
>
>> case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
>> XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV4ENA, 1);
>> XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV6ENA, 1);
>> @@ -1623,7 +1623,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
>> /* PTP v2, UDP, Sync packet */
>> case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
>> XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSVER2ENA, 1);
>> - /* PTP v1, UDP, Sync packet */
>> + /* Fall through - to PTP v1, UDP, Sync packet */
>> case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
>> XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV4ENA, 1);
>> XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV6ENA, 1);
>> @@ -1634,7 +1634,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
>> /* PTP v2, UDP, Delay_req packet */
>> case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
>> XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSVER2ENA, 1);
>> - /* PTP v1, UDP, Delay_req packet */
>> + /* Fall through - to PTP v1, UDP, Delay_req packet */
>> case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
>> XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV4ENA, 1);
>> XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV6ENA, 1);
>>

\
 
 \ /
  Last update: 2019-04-25 16:55    [W:0.051 / U:13.460 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site