diff mbox series

[RFC,v3,57/78] hw/net: add fallthrough pseudo-keyword

Message ID 84a6d743b5ff71c323cee718412e2a67084b9237.1697186560.git.manos.pitsidianakis@linaro.org
State New
Headers show
Series Strict disable implicit fallthrough | expand

Commit Message

Manos Pitsidianakis Oct. 13, 2023, 8:46 a.m. UTC
In preparation of raising -Wimplicit-fallthrough to 5, replace all
fall-through comments with the fallthrough attribute pseudo-keyword.

Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
---
 hw/net/cadence_gem.c     | 4 ++--
 hw/net/can/can_sja1000.c | 4 ++--
 hw/net/igb_core.c        | 2 +-
 hw/net/igbvf.c           | 2 +-
 hw/net/imx_fec.c         | 2 +-
 hw/net/net_rx_pkt.c      | 2 +-
 hw/net/pcnet.c           | 2 +-
 hw/net/rtl8139.c         | 6 ++++--
 hw/net/xilinx_ethlite.c  | 2 +-
 9 files changed, 14 insertions(+), 12 deletions(-)

Comments

Akihiko Odaki Oct. 13, 2023, 9:11 a.m. UTC | #1
On 2023/10/13 17:46, Emmanouil Pitsidianakis wrote:
> In preparation of raising -Wimplicit-fallthrough to 5, replace all
> fall-through comments with the fallthrough attribute pseudo-keyword.
> 
> Signed-off-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org>
> ---
>   hw/net/cadence_gem.c     | 4 ++--
>   hw/net/can/can_sja1000.c | 4 ++--
>   hw/net/igb_core.c        | 2 +-
>   hw/net/igbvf.c           | 2 +-
>   hw/net/imx_fec.c         | 2 +-
>   hw/net/net_rx_pkt.c      | 2 +-
>   hw/net/pcnet.c           | 2 +-
>   hw/net/rtl8139.c         | 6 ++++--
>   hw/net/xilinx_ethlite.c  | 2 +-
>   9 files changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
> index f445d8bb5e..a59991af5b 100644
> --- a/hw/net/cadence_gem.c
> +++ b/hw/net/cadence_gem.c
> @@ -834,10 +834,10 @@ static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr,
>                   qemu_log_mask(LOG_UNIMP, "TCP compare offsets"
>                                 "unimplemented - assuming UDP\n");
>                   offset += 8;
> -                /* Fallthrough */
> +                fallthrough;
>               case 2: /* skip the IP header */
>                   offset += 20;
> -                /* Fallthrough */
> +                fallthrough;
>               case 1: /* Count from after the ethertype */
>                   offset += 14;
>                   break;
> diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c
> index 73201f9139..14052b2700 100644
> --- a/hw/net/can/can_sja1000.c
> +++ b/hw/net/can/can_sja1000.c
> @@ -544,7 +544,7 @@ void can_sja_mem_write(CanSJA1000State *s, hwaddr addr, uint64_t val,
>               break;
>           case 16: /* RX frame information addr16-28. */
>               s->status_pel |= (1 << 5); /* Set transmit status. */
> -            /* fallthrough */
> +            fallthrough;
>           case 17 ... 28:
>               if (s->mode & 0x01) { /* Reset mode */
>                   if (addr < 24) {
> @@ -642,7 +642,7 @@ void can_sja_mem_write(CanSJA1000State *s, hwaddr addr, uint64_t val,
>               break;
>           case 10:
>               s->status_bas |= (1 << 5); /* Set transmit status. */
> -            /* fallthrough */
> +            fallthrough;
>           case 11 ... 19:
>               if ((s->control & 0x01) == 0) { /* Operation mode */
>                   s->tx_buff[addr - 10] = val; /* Store to TX buffer directly. */
> diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c
> index f6a5e2327b..1117f7cb59 100644
> --- a/hw/net/igb_core.c
> +++ b/hw/net/igb_core.c
> @@ -1419,7 +1419,7 @@ igb_build_rx_metadata_common(IGBCore *core,
>               if (!csum_valid) {
>                   *status_flags |= E1000_RXDEXT_STATERR_TCPE;
>               }
> -            /* fall through */
> +            fallthrough;
>           case ETH_L4_HDR_PROTO_TCP:
>               *status_flags |= E1000_RXD_STAT_TCPCS;
>               break;
> diff --git a/hw/net/igbvf.c b/hw/net/igbvf.c
> index d55e1e8a6a..ff68a4f3c5 100644
> --- a/hw/net/igbvf.c
> +++ b/hw/net/igbvf.c
> @@ -188,7 +188,7 @@ static hwaddr vf_to_pf_addr(hwaddr addr, uint16_t vfn, bool write)
>           if (write) {
>               return HWADDR_MAX;
>           }
> -        /* fallthrough */
> +        fallthrough;
>       case 0x34E8: /* PBTWAC */
>       case 0x24E8: /* PBRWAC */
>           return addr;
> diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
> index 5d1f1f104c..a7e8b06d48 100644
> --- a/hw/net/imx_fec.c
> +++ b/hw/net/imx_fec.c
> @@ -918,7 +918,7 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,
>                             TYPE_IMX_FEC, __func__);
>               return;
>           }
> -        /* fall through */
> +        fallthrough;
>       case ENET_TDAR:
>           if (s->regs[ENET_ECR] & ENET_ECR_ETHEREN) {
>               s->regs[index] = ENET_TDAR_TDAR;
> diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c
> index 32e5f3f9cf..52e2432c9b 100644
> --- a/hw/net/net_rx_pkt.c
> +++ b/hw/net/net_rx_pkt.c
> @@ -605,7 +605,7 @@ bool net_rx_pkt_validate_l4_csum(struct NetRxPkt *pkt, bool *csum_valid)
>               trace_net_rx_pkt_l4_csum_validate_udp_with_no_checksum();
>               return false;
>           }
> -        /* fall through */
> +        fallthrough;
>       case ETH_L4_HDR_PROTO_TCP:
>           csum = _net_rx_pkt_calc_l4_csum(pkt);
>           *csum_valid = ((csum == 0) || (csum == 0xFFFF));
> diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
> index 02828ae716..a32174ef93 100644
> --- a/hw/net/pcnet.c
> +++ b/hw/net/pcnet.c
> @@ -1502,7 +1502,7 @@ static void pcnet_bcr_writew(PCNetState *s, uint32_t rap, uint32_t val)
>   #ifdef PCNET_DEBUG
>          printf("BCR_SWS=0x%04x\n", val);
>   #endif
> -        /* fall through */
> +       fallthrough;
>       case BCR_LNKST:
>       case BCR_LED1:
>       case BCR_LED2:
> diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
> index 4525fda383..42f19618b1 100644
> --- a/hw/net/rtl8139.c
> +++ b/hw/net/rtl8139.c
> @@ -2447,8 +2447,10 @@ static uint32_t rtl8139_TxStatus_TxAddr_read(RTL8139State *s, uint32_t regs[],
>       }
>   
>       switch (size) {
> -    case 1: /* fall through */
> -    case 2: /* fall through */
> +    case 1:
> +        fallthrough;
> +    case 2:
> +        fallthrough;
>       case 4:

I don't think you need comments or pseudo-keywords here.
Manos Pitsidianakis Oct. 13, 2023, 9:20 a.m. UTC | #2
On Fri, 13 Oct 2023 at 12:11, Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
> > diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
> > index 4525fda383..42f19618b1 100644
> > --- a/hw/net/rtl8139.c
> > +++ b/hw/net/rtl8139.c
> > @@ -2447,8 +2447,10 @@ static uint32_t rtl8139_TxStatus_TxAddr_read(RTL8139State *s, uint32_t regs[],
> >       }
> >
> >       switch (size) {
> > -    case 1: /* fall through */
> > -    case 2: /* fall through */
> > +    case 1:
> > +        fallthrough;
> > +    case 2:
> > +        fallthrough;
> >       case 4:
>
> I don't think you need comments or pseudo-keywords here.

That's correct, it was a stylistic change. I can remove them in the
next version. Thank you!

Manos
diff mbox series

Patch

diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index f445d8bb5e..a59991af5b 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -834,10 +834,10 @@  static int get_queue_from_screen(CadenceGEMState *s, uint8_t *rxbuf_ptr,
                 qemu_log_mask(LOG_UNIMP, "TCP compare offsets"
                               "unimplemented - assuming UDP\n");
                 offset += 8;
-                /* Fallthrough */
+                fallthrough;
             case 2: /* skip the IP header */
                 offset += 20;
-                /* Fallthrough */
+                fallthrough;
             case 1: /* Count from after the ethertype */
                 offset += 14;
                 break;
diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c
index 73201f9139..14052b2700 100644
--- a/hw/net/can/can_sja1000.c
+++ b/hw/net/can/can_sja1000.c
@@ -544,7 +544,7 @@  void can_sja_mem_write(CanSJA1000State *s, hwaddr addr, uint64_t val,
             break;
         case 16: /* RX frame information addr16-28. */
             s->status_pel |= (1 << 5); /* Set transmit status. */
-            /* fallthrough */
+            fallthrough;
         case 17 ... 28:
             if (s->mode & 0x01) { /* Reset mode */
                 if (addr < 24) {
@@ -642,7 +642,7 @@  void can_sja_mem_write(CanSJA1000State *s, hwaddr addr, uint64_t val,
             break;
         case 10:
             s->status_bas |= (1 << 5); /* Set transmit status. */
-            /* fallthrough */
+            fallthrough;
         case 11 ... 19:
             if ((s->control & 0x01) == 0) { /* Operation mode */
                 s->tx_buff[addr - 10] = val; /* Store to TX buffer directly. */
diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c
index f6a5e2327b..1117f7cb59 100644
--- a/hw/net/igb_core.c
+++ b/hw/net/igb_core.c
@@ -1419,7 +1419,7 @@  igb_build_rx_metadata_common(IGBCore *core,
             if (!csum_valid) {
                 *status_flags |= E1000_RXDEXT_STATERR_TCPE;
             }
-            /* fall through */
+            fallthrough;
         case ETH_L4_HDR_PROTO_TCP:
             *status_flags |= E1000_RXD_STAT_TCPCS;
             break;
diff --git a/hw/net/igbvf.c b/hw/net/igbvf.c
index d55e1e8a6a..ff68a4f3c5 100644
--- a/hw/net/igbvf.c
+++ b/hw/net/igbvf.c
@@ -188,7 +188,7 @@  static hwaddr vf_to_pf_addr(hwaddr addr, uint16_t vfn, bool write)
         if (write) {
             return HWADDR_MAX;
         }
-        /* fallthrough */
+        fallthrough;
     case 0x34E8: /* PBTWAC */
     case 0x24E8: /* PBRWAC */
         return addr;
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
index 5d1f1f104c..a7e8b06d48 100644
--- a/hw/net/imx_fec.c
+++ b/hw/net/imx_fec.c
@@ -918,7 +918,7 @@  static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,
                           TYPE_IMX_FEC, __func__);
             return;
         }
-        /* fall through */
+        fallthrough;
     case ENET_TDAR:
         if (s->regs[ENET_ECR] & ENET_ECR_ETHEREN) {
             s->regs[index] = ENET_TDAR_TDAR;
diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c
index 32e5f3f9cf..52e2432c9b 100644
--- a/hw/net/net_rx_pkt.c
+++ b/hw/net/net_rx_pkt.c
@@ -605,7 +605,7 @@  bool net_rx_pkt_validate_l4_csum(struct NetRxPkt *pkt, bool *csum_valid)
             trace_net_rx_pkt_l4_csum_validate_udp_with_no_checksum();
             return false;
         }
-        /* fall through */
+        fallthrough;
     case ETH_L4_HDR_PROTO_TCP:
         csum = _net_rx_pkt_calc_l4_csum(pkt);
         *csum_valid = ((csum == 0) || (csum == 0xFFFF));
diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
index 02828ae716..a32174ef93 100644
--- a/hw/net/pcnet.c
+++ b/hw/net/pcnet.c
@@ -1502,7 +1502,7 @@  static void pcnet_bcr_writew(PCNetState *s, uint32_t rap, uint32_t val)
 #ifdef PCNET_DEBUG
        printf("BCR_SWS=0x%04x\n", val);
 #endif
-        /* fall through */
+       fallthrough;
     case BCR_LNKST:
     case BCR_LED1:
     case BCR_LED2:
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 4525fda383..42f19618b1 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -2447,8 +2447,10 @@  static uint32_t rtl8139_TxStatus_TxAddr_read(RTL8139State *s, uint32_t regs[],
     }
 
     switch (size) {
-    case 1: /* fall through */
-    case 2: /* fall through */
+    case 1:
+        fallthrough;
+    case 2:
+        fallthrough;
     case 4:
         ret = (regs[reg] >> offset * 8) & (((uint64_t)1 << (size * 8)) - 1);
         DPRINTF("TxStatus/TxAddr[%d] read addr=0x%x size=0x%x val=0x%08x\n",
diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c
index 89f4f3b254..5ae4032ec2 100644
--- a/hw/net/xilinx_ethlite.c
+++ b/hw/net/xilinx_ethlite.c
@@ -151,7 +151,7 @@  eth_write(void *opaque, hwaddr addr,
             if (!(value & CTRL_S)) {
                 qemu_flush_queued_packets(qemu_get_queue(s->nic));
             }
-            /* fall through */
+            fallthrough;
         case R_TX_LEN0:
         case R_TX_LEN1:
         case R_TX_GIE0: