[PATCH v2] Fix a bunch of implicit switch fallthrough warnings

Toke Høiland-Jørgensen toke at toke.dk
Sun Feb 11 18:57:50 CET 2018


GCC 7 turns on -Wimplicit-fallthrough by default[0], which results in a bunch of
warnings on a Bird build. This patch fixes those by either adding explicit
fall-through comments, or break statements.

[0] https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/

Signed-off-by: Toke Høiland-Jørgensen <toke at toke.dk>
---
v2:
- Missed one warning. Sorry for the noise.

 lib/printf.c        | 1 +
 proto/bfd/packets.c | 2 ++
 proto/ospf/dbdes.c  | 1 +
 proto/ospf/ospf.c   | 1 +
 proto/ospf/packet.c | 1 +
 proto/radv/radv.c   | 1 +
 sysdep/unix/io.c    | 5 +++++
 sysdep/unix/krt.c   | 1 +
 8 files changed, 13 insertions(+)

diff --git a/lib/printf.c b/lib/printf.c
index 533a1300..99bda862 100644
--- a/lib/printf.c
+++ b/lib/printf.c
@@ -413,6 +413,7 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args)
 
 		case 'X':
 			flags |= LARGE;
+			/* fall-through */
 		case 'x':
 			base = 16;
 			break;
diff --git a/proto/bfd/packets.c b/proto/bfd/packets.c
index b76efda6..137bb2f0 100644
--- a/proto/bfd/packets.c
+++ b/proto/bfd/packets.c
@@ -141,6 +141,7 @@ bfd_fill_authentication(struct bfd_proto *p, struct bfd_session *s, struct bfd_c
   case BFD_AUTH_METICULOUS_KEYED_MD5:
   case BFD_AUTH_METICULOUS_KEYED_SHA1:
     meticulous = 1;
+    /* fall-through */
 
   case BFD_AUTH_KEYED_MD5:
   case BFD_AUTH_KEYED_SHA1:
@@ -230,6 +231,7 @@ bfd_check_authentication(struct bfd_proto *p, struct bfd_session *s, struct bfd_
   case BFD_AUTH_METICULOUS_KEYED_MD5:
   case BFD_AUTH_METICULOUS_KEYED_SHA1:
     meticulous = 1;
+    /* fall-through */
 
   case BFD_AUTH_KEYED_MD5:
   case BFD_AUTH_KEYED_SHA1:
diff --git a/proto/ospf/dbdes.c b/proto/ospf/dbdes.c
index f211935f..7175b1ff 100644
--- a/proto/ospf/dbdes.c
+++ b/proto/ospf/dbdes.c
@@ -347,6 +347,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
     ospf_neigh_sm(n, INM_2WAYREC);
     if (n->state != NEIGHBOR_EXSTART)
       return;
+    /* fall-through */
 
   case NEIGHBOR_EXSTART:
     if ((ifa->type != OSPF_IT_VLINK) &&
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c
index df6c452e..b2d2d11e 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -1213,6 +1213,7 @@ ospf_sh_state(struct proto *P, int verbose, int reachable)
 	he->domain = 1; /* Abuse domain field to mark the LSA */
 	hex[jx++] = he;
       }
+      /* fall-through */
     default:
       accept = 0;
     }
diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c
index 38d7a75f..445f2006 100644
--- a/proto/ospf/packet.c
+++ b/proto/ospf/packet.c
@@ -56,6 +56,7 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt, uint *plen)
       return;
     }
     strncpy(auth->password, pass->password, sizeof(auth->password));
+    break;
 
   case OSPF_AUTH_NONE:
     {
diff --git a/proto/radv/radv.c b/proto/radv/radv.c
index 8a79dfaf..96984ff5 100644
--- a/proto/radv/radv.c
+++ b/proto/radv/radv.c
@@ -230,6 +230,7 @@ radv_iface_notify(struct radv_iface *ifa, int event)
   {
   case RA_EV_CHANGE:
     radv_invalidate(ifa);
+    /* fall-through */
   case RA_EV_INIT:
     ifa->initial = MAX_INITIAL_RTR_ADVERTISEMENTS;
     radv_prepare_prefixes(ifa);
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 012deaf0..ae827966 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -1176,6 +1176,7 @@ sk_ssh_connect(sock *s)
 	return SSH_ERROR;
     }
   }
+  break;
 
   case SK_SSH_USERAUTH:
   {
@@ -1192,6 +1193,7 @@ sk_ssh_connect(sock *s)
       return SSH_ERROR;
     }
   }
+  break;
 
   case SK_SSH_CHANNEL:
   {
@@ -1200,6 +1202,7 @@ sk_ssh_connect(sock *s)
     if (s->ssh->channel == NULL)
       return SSH_ERROR;
   }
+  break;
 
   case SK_SSH_SESSION:
   {
@@ -1216,6 +1219,7 @@ sk_ssh_connect(sock *s)
       return SSH_ERROR;
     }
   }
+  break;
 
   case SK_SSH_SUBSYSTEM:
   {
@@ -1234,6 +1238,7 @@ sk_ssh_connect(sock *s)
 	return SSH_ERROR;
       }
     }
+    break;
   }
 
   case SK_SSH_ESTABLISHED:
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c
index a3cbb336..04799ad4 100644
--- a/sysdep/unix/krt.c
+++ b/sysdep/unix/krt.c
@@ -789,6 +789,7 @@ krt_got_route_async(struct krt_proto *p, rte *e, int new)
     {
     case KRT_SRC_BIRD:
       ASSERT(0);			/* Should be filtered by the back end */
+      break;
 
     case KRT_SRC_REDIRECT:
       if (new)
-- 
2.16.1



More information about the Bird-users mailing list