From 5cff40bc0e9ae4dd575bff9fc1643573a57bdc91 Mon Sep 17 00:00:00 2001 From: claudio Date: Fri, 28 Apr 2023 13:24:25 +0000 Subject: [PATCH] Same change as in bgpd: Add explicit default labels in switch() statements with error handling. Right now these are not reachable. Should also clear some gcc warnings. OK tb@ --- usr.sbin/bgpctl/bgpctl.c | 4 +++- usr.sbin/bgpctl/output.c | 17 ++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index b7b484d4662..981f33ff4ff 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.294 2023/04/23 11:39:51 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.295 2023/04/28 13:24:25 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -2035,6 +2035,8 @@ push_prefix(struct parse_result *r, int type, struct bgpd_addr *addr, complen = PREFIX_SIZE(len) + 1; data = &addr->v6; break; + default: + errx(1, "unsupported address family for flowspec address"); } comp = malloc(complen); if (comp == NULL) diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index b12b363187a..d50a62c7dae 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.40 2023/04/21 10:49:01 claudio Exp $ */ +/* $OpenBSD: output.c,v 1.41 2023/04/28 13:24:25 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -526,12 +526,6 @@ print_flowspec_flags(struct flowspec *f, int type, int is_v6) const char *fmt, *flags; int complen, off = 0; - if (flowspec_get_component(f->data, f->len, type, is_v6, - &comp, &complen) != 1) - return; - - printf("%s ", flowspec_fmt_label(type)); - switch (type) { case FLOWSPEC_TYPE_TCP_FLAGS: flags = FLOWSPEC_TCP_FLAG_STRING; @@ -542,8 +536,17 @@ print_flowspec_flags(struct flowspec *f, int type, int is_v6) else flags = FLOWSPEC_FRAG_STRING6; break; + default: + printf("??? "); + return; } + if (flowspec_get_component(f->data, f->len, type, is_v6, + &comp, &complen) != 1) + return; + + printf("%s ", flowspec_fmt_label(type)); + fmt = flowspec_fmt_bin_op(comp, complen, &off, flags); if (off == -1) { printf("%s ", fmt); -- 2.20.1