lib: Add missing enum's to switch statement

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2023-01-30 10:06:29 -05:00
parent a98701f053
commit bde30e78cb
14 changed files with 117 additions and 35 deletions

View 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;
}
}

View 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);

View 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."

View 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;
}

View 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)

View 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)

View 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;
}

View 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;
}
}

View 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;
}

View 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);

View File

@ -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;
}

View File

@ -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");
}
}

View 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;
}

View 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;