Commit 1db44fe51d for frr
commit 1db44fe51d92c2dd067e960718d0d1258a7ef7e8
Author: Donald Sharp <sharpd@nvidia.com>
Date: Thu Nov 26 15:21:12 2026 -0500
mgmtd: avoid -Wswitch-enum failure on LYD_CBOR in mgmt_vty_frontend
libyang 6 adds LYD_CBOR to enum LYD_FORMAT, which causes a
-Wswitch-enum error under --enable-dev-build (-Werror) on the switch
over LYD_FORMAT in vty_out_yang_error().
Use if/else if/else for LYD_XML, LYD_JSON, and the fallback path so
all current and future LYD_FORMAT values compile cleanly without
warnings.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
diff --git a/mgmtd/mgmt_vty_frontend.c b/mgmtd/mgmt_vty_frontend.c
index c1e787ea58..9c6e2cd604 100644
--- a/mgmtd/mgmt_vty_frontend.c
+++ b/mgmtd/mgmt_vty_frontend.c
@@ -221,8 +221,7 @@ static void vty_out_yang_error(struct vty *vty, LYD_FORMAT format, const struct
if (err == LY_EVALID && ei->vecode != LYVE_SUCCESS)
evalid = ly_strvecode(ei->vecode);
- switch (format) {
- case LYD_XML:
+ if (format == LYD_XML) {
vty_out(vty, "<rpc-error xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">");
vty_out(vty, "<error-type>application</error-type>");
if (severity)
@@ -239,8 +238,7 @@ static void vty_out_yang_error(struct vty *vty, LYD_FORMAT format, const struct
vty_out(vty, "<error-message>%s</error-message>\n", ei->msg);
vty_out(vty, "</rpc-error>");
- break;
- case LYD_JSON:
+ } else if (format == LYD_JSON) {
vty_out(vty, "{ \"error-type\": \"application\"");
if (severity)
vty_out(vty, ", \"error-severity\": \"%s\"", severity);
@@ -256,10 +254,7 @@ static void vty_out_yang_error(struct vty *vty, LYD_FORMAT format, const struct
vty_out(vty, ", \"error-message\": \"%s\"", ei->msg);
vty_out(vty, "}");
- break;
- case LYD_UNKNOWN:
- case LYD_LYB:
- default:
+ } else {
vty_out(vty, "%% error");
if (severity)
vty_out(vty, " severity: %s", severity);
@@ -271,7 +266,6 @@ static void vty_out_yang_error(struct vty *vty, LYD_FORMAT format, const struct
vty_out(vty, " app-tag: %s", ei->apptag);
if (have_msg)
vty_out(vty, " msg: %s", ei->msg);
- break;
}
#undef data_path
}