]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: Add missing enum's to switch statement
authorDonald Sharp <sharpd@nvidia.com>
Mon, 30 Jan 2023 15:06:29 +0000 (10:06 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Tue, 31 Jan 2023 20:15:42 +0000 (15:15 -0500)
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
14 files changed:
lib/command.c
lib/command_graph.c
lib/command_match.c
lib/grammar_sandbox.c
lib/iana_afi.h
lib/ipaddr.h
lib/link_state.c
lib/prefix.c
lib/routemap.c
lib/stream.c
lib/vrf.c
lib/vty.c
lib/zclient.c
lib/zlog_5424_cli.c

index 6d023142ab681ad5dae236f599c71d651dee3873..4e8194bbc6e854bc30efd3ab60dcd8fca9333125 100644 (file)
@@ -949,7 +949,8 @@ static int cmd_execute_command_real(vector vline, enum cmd_filter_type filter,
                        return CMD_ERR_INCOMPLETE;
                case MATCHER_AMBIGUOUS:
                        return CMD_ERR_AMBIGUOUS;
-               default:
+               case MATCHER_NO_MATCH:
+               case MATCHER_OK:
                        return CMD_ERR_NO_MATCH;
                }
        }
index e940685250fad5343f9a670646913dfcaa963ca8..766d7e937197b051c907e36a412bdaf449f5f913 100644 (file)
@@ -267,9 +267,22 @@ static bool cmd_nodes_equal(struct graph_node *ga, struct graph_node *gb)
                        return false;
                return cmd_subgraph_equal(ga, gb, a->forkjoin);
 
-       default:
+       case VARIABLE_TKN:
+       case IPV4_TKN:
+       case IPV4_PREFIX_TKN:
+       case IPV6_PREFIX_TKN:
+       case IPV6_TKN:
+       case MAC_TKN:
+       case MAC_PREFIX_TKN:
+       case JOIN_TKN:
+       case START_TKN:
+       case END_TKN:
+       case NEG_ONLY_TKN:
+       case WORD_TKN:
                return true;
        }
+
+       assert(!"Reached end of function we should never hit");
 }
 
 static void cmd_fork_bump_attr(struct graph_node *gn, struct graph_node *join,
@@ -477,7 +490,7 @@ void cmd_graph_node_print_cb(struct graph_node *gn, struct buffer *buf)
 
        char nbuf[512];
        struct cmd_token *tok = gn->data;
-       const char *color;
+       const char *color = NULL;
 
        if (wasend) {
                wasend = false;
@@ -526,10 +539,23 @@ void cmd_graph_node_print_cb(struct graph_node *gn, struct buffer *buf)
        case WORD_TKN:
                color = "#ffffff";
                break;
-       default:
+       case RANGE_TKN:
+       case IPV4_TKN:
+       case IPV4_PREFIX_TKN:
+       case IPV6_TKN:
+       case IPV6_PREFIX_TKN:
+       case MAC_TKN:
+       case MAC_PREFIX_TKN:
+       case END_TKN:
+       case VARIABLE_TKN:
                color = "#ffffff";
                break;
        }
+
+       /*
+        * Some compilers have the mistaken belief that we can
+        * get here without initializing color.
+        */
        snprintf(nbuf, sizeof(nbuf),
                 ">, style = filled, fillcolor = \"%s\" ];\n", color);
        buffer_putstr(buf, nbuf);
index ce2dbc9528997ad5997146baaaebd77ee429896b..6c1d05d92657bdac6994d6838375f8e64c5284f1 100644 (file)
@@ -437,7 +437,7 @@ enum matcher_rv command_complete(struct graph *graph, vector vline,
                                        add_nexthops(next, gstack[0], gstack,
                                                     idx + 1, neg);
                                break;
-                       default:
+                       case no_match:
                                trace_matcher("no_match\n");
                                break;
                        }
@@ -544,9 +544,22 @@ static enum match_type min_match_level(enum cmd_token_type type)
        // allowing words to partly match enables command abbreviation
        case WORD_TKN:
                return partly_match;
-       default:
+       case RANGE_TKN:
+       case IPV4_TKN:
+       case IPV4_PREFIX_TKN:
+       case IPV6_TKN:
+       case IPV6_PREFIX_TKN:
+       case MAC_TKN:
+       case MAC_PREFIX_TKN:
+       case FORK_TKN:
+       case JOIN_TKN:
+       case END_TKN:
+       case NEG_ONLY_TKN:
+       case VARIABLE_TKN:
                return exact_match;
        }
+
+       assert(!"Reached end of function we should never hit");
 }
 
 /**
@@ -572,9 +585,15 @@ static int score_precedence(enum cmd_token_type type)
                return 3;
        case VARIABLE_TKN:
                return 4;
-       default:
+       case JOIN_TKN:
+       case START_TKN:
+       case END_TKN:
+       case NEG_ONLY_TKN:
+       case SPECIAL_TKN:
                return 10;
        }
+
+       assert(!"Reached end of function we should never hit");
 }
 
 /**
@@ -695,9 +714,14 @@ static enum match_type match_token(struct cmd_token *token, char *input_token)
        case MAC_PREFIX_TKN:
                return match_mac(input_token, true);
        case END_TKN:
-       default:
+       case FORK_TKN:
+       case JOIN_TKN:
+       case START_TKN:
+       case NEG_ONLY_TKN:
                return no_match;
        }
+
+       assert(!"Reached end of function we should never hit");
 }
 
 #define IPV4_ADDR_STR   "0123456789."
index 8fa47c053bcfaaa7d82ea9590b59c2291c9bf5fd..a62178ba0a67083698701b448d58d956cca553ac 100644 (file)
@@ -195,7 +195,7 @@ DEFUN (grammar_test_match,
                case MATCHER_AMBIGUOUS:
                        vty_out(vty, "%% Ambiguous command\n");
                        break;
-               default:
+               case MATCHER_OK:
                        vty_out(vty, "%% Unknown error\n");
                        break;
                }
index 56e8a24b86f119c26cb6d27dbb436fe6dc4a224b..41e83d45c88b2b147e818f9a8af35135218833f7 100644 (file)
@@ -61,9 +61,11 @@ static inline afi_t afi_iana2int(iana_afi_t afi)
                return AFI_IP6;
        case IANA_AFI_L2VPN:
                return AFI_L2VPN;
-       default:
+       case IANA_AFI_RESERVED:
                return AFI_MAX;
        }
+
+       return AFI_MAX;
 }
 
 static inline iana_afi_t afi_int2iana(afi_t afi)
@@ -75,9 +77,12 @@ static inline iana_afi_t afi_int2iana(afi_t afi)
                return IANA_AFI_IPV6;
        case AFI_L2VPN:
                return IANA_AFI_L2VPN;
-       default:
+       case AFI_UNSPEC:
+       case AFI_MAX:
                return IANA_AFI_RESERVED;
        }
+
+       return IANA_AFI_RESERVED;
 }
 
 static inline const char *iana_afi2str(iana_afi_t afi)
@@ -102,9 +107,11 @@ static inline safi_t safi_iana2int(iana_safi_t safi)
                return SAFI_LABELED_UNICAST;
        case IANA_SAFI_FLOWSPEC:
                return SAFI_FLOWSPEC;
-       default:
+       case IANA_SAFI_RESERVED:
                return SAFI_MAX;
        }
+
+       return SAFI_MAX;
 }
 
 static inline iana_safi_t safi_int2iana(safi_t safi)
@@ -124,9 +131,12 @@ static inline iana_safi_t safi_int2iana(safi_t safi)
                return IANA_SAFI_LABELED_UNICAST;
        case SAFI_FLOWSPEC:
                return IANA_SAFI_FLOWSPEC;
-       default:
+       case SAFI_UNSPEC:
+       case SAFI_MAX:
                return IANA_SAFI_RESERVED;
        }
+
+       return IANA_SAFI_RESERVED;
 }
 
 static inline const char *iana_safi2str(iana_safi_t safi)
index 43b3028200c7e9c71d0a81497833b2cac61a7d61..4934a83b4cb8b2d26757e510bd34677a4bf41dff 100644 (file)
@@ -70,9 +70,11 @@ static inline int ipaddr_family(const struct ipaddr *ip)
                return AF_INET;
        case IPADDR_V6:
                return AF_INET6;
-       default:
+       case IPADDR_NONE:
                return AF_UNSPEC;
        }
+
+       assert(!"Reached end of function where we should never hit");
 }
 
 static inline int str2ipaddr(const char *str, struct ipaddr *ip)
@@ -158,9 +160,11 @@ static inline int ipaddr_cmp(const struct ipaddr *a, const struct ipaddr *b)
        case IPADDR_V6:
                return memcmp((void *)&a->ipaddr_v6, (void *)&b->ipaddr_v6,
                              sizeof(a->ipaddr_v6));
-       default:
+       case IPADDR_NONE:
                return 0;
        }
+
+       assert(!"Reached end of function we should never hit");
 }
 
 static inline bool ipaddr_is_zero(const struct ipaddr *ip)
index 1b79c792164ebc6de2bd9185158d0aa9946e46ed..c59cd040c8c32969f034d0360bd7e1a2b554d07c 100644 (file)
@@ -443,7 +443,7 @@ struct ls_vertex *ls_vertex_add(struct ls_ted *ted, struct ls_node *node)
        case ISIS_L2:
                key = sysid_to_key(node->adv.id.iso.sys_id);
                break;
-       default:
+       case UNKNOWN:
                key = 0;
                break;
        }
@@ -565,7 +565,7 @@ struct ls_vertex *ls_find_vertex_by_id(struct ls_ted *ted,
        case ISIS_L2:
                vertex.key = sysid_to_key(nid.id.iso.sys_id);
                break;
-       default:
+       case UNKNOWN:
                return NULL;
        }
 
@@ -1649,7 +1649,8 @@ struct ls_message *ls_vertex2msg(struct ls_message *msg,
        case SYNC:
                msg->event = LS_MSG_EVENT_SYNC;
                break;
-       default:
+       case UNSET:
+       case ORPHAN:
                msg->event = LS_MSG_EVENT_UNDEF;
                break;
        }
@@ -1681,7 +1682,8 @@ struct ls_message *ls_edge2msg(struct ls_message *msg, struct ls_edge *edge)
        case SYNC:
                msg->event = LS_MSG_EVENT_SYNC;
                break;
-       default:
+       case UNSET:
+       case ORPHAN:
                msg->event = LS_MSG_EVENT_UNDEF;
                break;
        }
@@ -1717,7 +1719,8 @@ struct ls_message *ls_subnet2msg(struct ls_message *msg,
        case SYNC:
                msg->event = LS_MSG_EVENT_SYNC;
                break;
-       default:
+       case UNSET:
+       case ORPHAN:
                msg->event = LS_MSG_EVENT_UNDEF;
                break;
        }
index 1d098f78c5e563b3eb84a9da51c13778c9341df0..9d6dc735722bb8325e70d0ea12dda06e3aae92c5 100644 (file)
@@ -148,11 +148,11 @@ const char *afi2str(afi_t afi)
        case AFI_L2VPN:
                return "l2vpn";
        case AFI_MAX:
+       case AFI_UNSPEC:
                return "bad-value";
-       default:
-               break;
        }
-       return NULL;
+
+       assert(!"Reached end of function we should never reach");
 }
 
 const char *safi2str(safi_t safi)
@@ -172,9 +172,12 @@ const char *safi2str(safi_t safi)
                return "labeled-unicast";
        case SAFI_FLOWSPEC:
                return "flowspec";
-       default:
+       case SAFI_UNSPEC:
+       case SAFI_MAX:
                return "unknown";
        }
+
+       assert(!"Reached end of function we should never reach");
 }
 
 /* If n includes p prefix then return 1 else return 0. */
@@ -1507,7 +1510,7 @@ static ssize_t printfrr_ia(struct fbuf *buf, struct printfrr_eargs *ea,
                                return bputch(buf, '*');
                        break;
 
-               default:
+               case IPADDR_NONE:
                        break;
                }
        }
index 44d7185567a6d549f8c68ec07c5afba5a7bda296..f56e6a612201be5f3ec87de869a7e1c1a45511b6 100644 (file)
@@ -1754,7 +1754,8 @@ route_map_apply_match(struct route_map_rule_list *match_list,
                                        ret = RMAP_MATCH;
                                break;
 
-                       default:
+                       case RMAP_OKAY:
+                       case RMAP_ERROR:
                                break;
                        }
 
index 2de3abdf45fc654dc4151e8172de2f22375c10e6..0756f902749b00346e1585dc1fe277d2e3885e98 100644 (file)
@@ -635,7 +635,7 @@ uint32_t stream_get_ipv4(struct stream *s)
 
 bool stream_get_ipaddr(struct stream *s, struct ipaddr *ip)
 {
-       uint16_t ipa_len;
+       uint16_t ipa_len = 0;
 
        STREAM_VERIFY_SANE(s);
 
@@ -654,7 +654,7 @@ bool stream_get_ipaddr(struct stream *s, struct ipaddr *ip)
        case IPADDR_V6:
                ipa_len = IPV6_MAX_BYTELEN;
                break;
-       default:
+       case IPADDR_NONE:
                flog_err(EC_LIB_DEVELOPMENT,
                         "%s: unknown ip address-family: %u", __func__,
                         ip->ipa_type);
@@ -947,7 +947,7 @@ bool stream_put_ipaddr(struct stream *s, struct ipaddr *ip)
        case IPADDR_V6:
                stream_write(s, (uint8_t *)&ip->ipaddr_v6, 16);
                break;
-       default:
+       case IPADDR_NONE:
                flog_err(EC_LIB_DEVELOPMENT,
                         "%s: unknown ip address-family: %u", __func__,
                         ip->ipa_type);
index 7d2ca6f1e1e7f6a4d87eb0e330af50f31c742f48..baf25dfa0ec3c70bddfd87a9725837ea0ee2a293 100644 (file)
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -610,7 +610,7 @@ int vrf_configure_backend(enum vrf_backend_type backend)
        case VRF_BACKEND_NETNS:
        case VRF_BACKEND_VRF_LITE:
                break;
-       default:
+       case VRF_BACKEND_MAX:
                return -1;
        }
 
index 76d907408c30aac0a8e41eca579847fd42a5678a..d53e07fe4276b5e40467a3e7a436ec9ce5b052b3 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2714,7 +2714,11 @@ static void vty_event_serv(enum vty_event event, struct vty_serv *vty_serv)
                                vty_serv->sock, &vty_serv->t_accept);
                break;
 #endif /* VTYSH */
-       default:
+       case VTY_READ:
+       case VTY_WRITE:
+       case VTY_TIMEOUT_RESET:
+       case VTYSH_READ:
+       case VTYSH_WRITE:
                assert(!"vty_event_serv() called incorrectly");
        }
 }
@@ -2753,7 +2757,8 @@ static void vty_event(enum vty_event event, struct vty *vty)
                        thread_add_timer(vty_master, vty_timeout, vty,
                                         vty->v_timeout, &vty->t_timeout);
                break;
-       default:
+       case VTY_SERV:
+       case VTYSH_SERV:
                assert(!"vty_event() called incorrectly");
        }
 }
index 07c7e5aea8953bfe8855e2c489fdb8a6e0c1b4c9..d748bef3352f92659aa6261c509a115db2f9955d 100644 (file)
@@ -1682,7 +1682,8 @@ int zapi_tc_class_encode(uint8_t cmd, struct stream *s, struct tc_class *class)
                stream_putq(s, class->u.htb.rate);
                stream_putq(s, class->u.htb.ceil);
                break;
-       default:
+       case TC_QDISC_UNSPEC:
+       case TC_QDISC_NOQUEUE:
                /* not implemented */
                break;
        }
@@ -1730,7 +1731,10 @@ int zapi_tc_filter_encode(uint8_t cmd, struct stream *s,
                }
                stream_putl(s, filter->u.flower.classid);
                break;
-       default:
+       case TC_FILTER_UNSPEC:
+       case TC_FILTER_BPF:
+       case TC_FILTER_FLOW:
+       case TC_FILTER_U32:
                /* not implemented */
                break;
        }
index 5eebda9debc4a4b50737746cdffc6a30a415857c..be0988e0b341a76dd809c769c0e65669ef1b35bd 100644 (file)
@@ -877,7 +877,8 @@ static int log_5424_show(struct vty *vty)
                        }
                        break;
 
-               default:
+               case ZLOG_FMT_3164:
+               case ZLOG_FMT_LOCAL:
                        vty_out(vty,
                                "  structured data is not supported by the selected format\n");
                        break;