summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2023-01-26 14:56:04 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2023-01-27 12:01:20 +0100
commitae08de9f427ec6b71299ae2786cff19b98d0468f (patch)
treeeac8b492c20355de2a6e1e787cb00f0abfefb04f
parent*: no-warn pragmas for non-const format strings (diff)
downloadfrr-ae08de9f427ec6b71299ae2786cff19b98d0468f.tar.xz
frr-ae08de9f427ec6b71299ae2786cff19b98d0468f.zip
*: fix non-const northbound XPath format strings
Passing a pre-formatted buffer in these places needs a `"%s"` in front so it doesn't get formatted twice. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
-rw-r--r--isisd/isis_cli.c4
-rw-r--r--lib/filter_cli.c24
-rw-r--r--lib/filter_nb.c19
-rw-r--r--lib/if.c4
-rw-r--r--lib/vrf.c2
-rw-r--r--pathd/path_nb.c2
-rw-r--r--pimd/pim_cmd.c14
-rw-r--r--pimd/pim_cmd_common.c4
-rw-r--r--staticd/static_vty.c4
9 files changed, 36 insertions, 41 deletions
diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c
index 3650984f1..cb607deb2 100644
--- a/isisd/isis_cli.c
+++ b/isisd/isis_cli.c
@@ -61,7 +61,7 @@ DEFPY_YANG_NOSH(router_isis, router_isis_cmd,
vrf_name);
nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
- ret = nb_cli_apply_changes(vty, base_xpath);
+ ret = nb_cli_apply_changes(vty, "%s", base_xpath);
if (ret == CMD_SUCCESS)
VTY_PUSH_XPATH(ISIS_NODE, base_xpath);
@@ -1427,7 +1427,7 @@ DEFPY_YANG(
overload ? "true" : "false");
}
- return nb_cli_apply_changes(vty, base_xpath);
+ return nb_cli_apply_changes(vty, "%s", base_xpath);
}
void cli_show_isis_mt_ipv4_multicast(struct vty *vty,
diff --git a/lib/filter_cli.c b/lib/filter_cli.c
index 296c05b9f..5accea3f0 100644
--- a/lib/filter_cli.c
+++ b/lib/filter_cli.c
@@ -206,7 +206,7 @@ DEFPY_YANG(
nb_cli_enqueue_change(vty, "./source-any", NB_OP_CREATE, NULL);
}
- return nb_cli_apply_changes(vty, xpath_entry);
+ return nb_cli_apply_changes(vty, "%s", xpath_entry);
}
DEFPY_YANG(
@@ -369,7 +369,7 @@ DEFPY_YANG(
NULL);
}
- return nb_cli_apply_changes(vty, xpath_entry);
+ return nb_cli_apply_changes(vty, "%s", xpath_entry);
}
DEFPY_YANG(
@@ -519,7 +519,7 @@ DEFPY_YANG(
nb_cli_enqueue_change(vty, "./any", NB_OP_CREATE, NULL);
}
- return nb_cli_apply_changes(vty, xpath_entry);
+ return nb_cli_apply_changes(vty, "%s", xpath_entry);
}
DEFPY_YANG(
@@ -600,7 +600,7 @@ DEFPY_YANG(
remark = argv_concat(argv, argc, 3);
nb_cli_enqueue_change(vty, "./remark", NB_OP_CREATE, remark);
- rv = nb_cli_apply_changes(vty, xpath);
+ rv = nb_cli_apply_changes(vty, "%s", xpath);
XFREE(MTYPE_TMP, remark);
return rv;
@@ -709,7 +709,7 @@ DEFPY_YANG(
nb_cli_enqueue_change(vty, "./any", NB_OP_CREATE, NULL);
}
- return nb_cli_apply_changes(vty, xpath_entry);
+ return nb_cli_apply_changes(vty, "%s", xpath_entry);
}
DEFPY_YANG(
@@ -793,7 +793,7 @@ DEFPY_YANG(
remark = argv_concat(argv, argc, 4);
nb_cli_enqueue_change(vty, "./remark", NB_OP_CREATE, remark);
- rv = nb_cli_apply_changes(vty, xpath);
+ rv = nb_cli_apply_changes(vty, "%s", xpath);
XFREE(MTYPE_TMP, remark);
return rv;
@@ -896,7 +896,7 @@ DEFPY_YANG(
nb_cli_enqueue_change(vty, "./any", NB_OP_CREATE, NULL);
}
- return nb_cli_apply_changes(vty, xpath_entry);
+ return nb_cli_apply_changes(vty, "%s", xpath_entry);
}
DEFPY_YANG(
@@ -975,7 +975,7 @@ DEFPY_YANG(
remark = argv_concat(argv, argc, 4);
nb_cli_enqueue_change(vty, "./remark", NB_OP_CREATE, remark);
- rv = nb_cli_apply_changes(vty, xpath);
+ rv = nb_cli_apply_changes(vty, "%s", xpath);
XFREE(MTYPE_TMP, remark);
return rv;
@@ -1344,7 +1344,7 @@ DEFPY_YANG(
nb_cli_enqueue_change(vty, "./any", NB_OP_CREATE, NULL);
}
- return nb_cli_apply_changes(vty, xpath_entry);
+ return nb_cli_apply_changes(vty, "%s", xpath_entry);
}
DEFPY_YANG(
@@ -1415,7 +1415,7 @@ DEFPY_YANG(
remark = argv_concat(argv, argc, 4);
nb_cli_enqueue_change(vty, "./remark", NB_OP_CREATE, remark);
- rv = nb_cli_apply_changes(vty, xpath);
+ rv = nb_cli_apply_changes(vty, "%s", xpath);
XFREE(MTYPE_TMP, remark);
return rv;
@@ -1548,7 +1548,7 @@ DEFPY_YANG(
nb_cli_enqueue_change(vty, "./any", NB_OP_CREATE, NULL);
}
- return nb_cli_apply_changes(vty, xpath_entry);
+ return nb_cli_apply_changes(vty, "%s", xpath_entry);
}
DEFPY_YANG(
@@ -1619,7 +1619,7 @@ DEFPY_YANG(
remark = argv_concat(argv, argc, 4);
nb_cli_enqueue_change(vty, "./remark", NB_OP_CREATE, remark);
- rv = nb_cli_apply_changes(vty, xpath);
+ rv = nb_cli_apply_changes(vty, "%s", xpath);
XFREE(MTYPE_TMP, remark);
return rv;
diff --git a/lib/filter_nb.c b/lib/filter_nb.c
index 3ed1f3e03..cfe310538 100644
--- a/lib/filter_nb.c
+++ b/lib/filter_nb.c
@@ -70,7 +70,7 @@ static enum nb_error prefix_list_length_validate(struct nb_cb_modify_args *args)
* prefix length <= le.
*/
if (yang_dnode_exists(args->dnode, xpath_le)) {
- le = yang_dnode_get_uint8(args->dnode, xpath_le);
+ le = yang_dnode_get_uint8(args->dnode, "%s", xpath_le);
if (p.prefixlen > le)
goto log_and_fail;
}
@@ -80,7 +80,7 @@ static enum nb_error prefix_list_length_validate(struct nb_cb_modify_args *args)
* prefix length <= ge.
*/
if (yang_dnode_exists(args->dnode, xpath_ge)) {
- ge = yang_dnode_get_uint8(args->dnode, xpath_ge);
+ ge = yang_dnode_get_uint8(args->dnode, "%s", xpath_ge);
if (p.prefixlen > ge)
goto log_and_fail;
}
@@ -91,8 +91,8 @@ static enum nb_error prefix_list_length_validate(struct nb_cb_modify_args *args)
*/
if (yang_dnode_exists(args->dnode, xpath_le)
&& yang_dnode_exists(args->dnode, xpath_ge)) {
- le = yang_dnode_get_uint8(args->dnode, xpath_le);
- ge = yang_dnode_get_uint8(args->dnode, xpath_ge);
+ le = yang_dnode_get_uint8(args->dnode, "%s", xpath_le);
+ ge = yang_dnode_get_uint8(args->dnode, "%s", xpath_ge);
if (ge > le)
goto log_and_fail;
}
@@ -273,7 +273,8 @@ static int _acl_is_dup(const struct lyd_node *dnode, void *arg)
return YANG_ITER_CONTINUE;
/* Check if different value. */
- if (strcmp(yang_dnode_get_string(dnode, ada->ada_xpath[idx]),
+ if (strcmp(yang_dnode_get_string(dnode, "%s",
+ ada->ada_xpath[idx]),
ada->ada_value[idx]))
return YANG_ITER_CONTINUE;
}
@@ -328,8 +329,8 @@ static bool acl_cisco_is_dup(const struct lyd_node *dnode)
}
ada.ada_xpath[arg_idx] = cisco_entries[idx];
- ada.ada_value[arg_idx] =
- yang_dnode_get_string(entry_dnode, cisco_entries[idx]);
+ ada.ada_value[arg_idx] = yang_dnode_get_string(
+ entry_dnode, "%s", cisco_entries[idx]);
arg_idx++;
idx++;
}
@@ -378,8 +379,8 @@ static bool acl_zebra_is_dup(const struct lyd_node *dnode,
}
ada.ada_xpath[arg_idx] = zebra_entries[idx];
- ada.ada_value[arg_idx] =
- yang_dnode_get_string(entry_dnode, zebra_entries[idx]);
+ ada.ada_value[arg_idx] = yang_dnode_get_string(
+ entry_dnode, "%s", zebra_entries[idx]);
arg_idx++;
idx++;
}
diff --git a/lib/if.c b/lib/if.c
index db7321003..b75c2a4db 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -1220,7 +1220,7 @@ DEFPY_YANG_NOSH (interface,
}
nb_cli_enqueue_change(vty, ".", NB_OP_CREATE, NULL);
- ret = nb_cli_apply_changes_clear_pending(vty, xpath_list);
+ ret = nb_cli_apply_changes_clear_pending(vty, "%s", xpath_list);
if (ret == CMD_SUCCESS) {
VTY_PUSH_XPATH(INTERFACE_NODE, xpath_list);
@@ -1279,7 +1279,7 @@ DEFPY_YANG (no_interface,
nb_cli_enqueue_change(vty, ".", NB_OP_DESTROY, NULL);
- return nb_cli_apply_changes(vty, xpath_list);
+ return nb_cli_apply_changes(vty, "%s", xpath_list);
}
static void netns_ifname_split(const char *xpath, char *ifname, char *vrfname)
diff --git a/lib/vrf.c b/lib/vrf.c
index 2ac7ef7a9..7d2ca6f1e 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -652,7 +652,7 @@ DEFUN_YANG_NOSH (vrf,
snprintf(xpath_list, sizeof(xpath_list), FRR_VRF_KEY_XPATH, vrfname);
nb_cli_enqueue_change(vty, xpath_list, NB_OP_CREATE, NULL);
- ret = nb_cli_apply_changes_clear_pending(vty, xpath_list);
+ ret = nb_cli_apply_changes_clear_pending(vty, "%s", xpath_list);
if (ret == CMD_SUCCESS) {
VTY_PUSH_XPATH(VRF_NODE, xpath_list);
vrf = vrf_lookup_by_name(vrfname);
diff --git a/pathd/path_nb.c b/pathd/path_nb.c
index 1ab8b7f39..137e64d12 100644
--- a/pathd/path_nb.c
+++ b/pathd/path_nb.c
@@ -310,7 +310,7 @@ void iter_objfun_prefs(const struct lyd_node *dnode, const char* path,
struct of_cb_args args = {0};
struct of_cb_pref *p;
- yang_dnode_iterate(iter_objfun_cb, &args, dnode, path);
+ yang_dnode_iterate(iter_objfun_cb, &args, dnode, "%s", path);
for (p = args.first; p != NULL; p = p->next)
fun(p->type, arg);
}
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 306891c0e..d73ec2990 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -4777,14 +4777,11 @@ DEFPY(ip_msdp_timers, ip_msdp_timers_cmd,
"Connection retry period (in seconds)\n")
{
const char *vrfname;
- char xpath[XPATH_MAXLEN];
vrfname = pim_cli_get_vrf_name(vty);
if (vrfname == NULL)
return CMD_WARNING_CONFIG_FAILED;
- snprintf(xpath, sizeof(xpath), FRR_PIM_MSDP_XPATH, "frr-pim:pimd",
- "pim", vrfname, "frr-routing:ipv4");
nb_cli_enqueue_change(vty, "./hold-time", NB_OP_MODIFY, holdtime_str);
nb_cli_enqueue_change(vty, "./keep-alive", NB_OP_MODIFY, keepalive_str);
if (connretry_str)
@@ -4794,8 +4791,8 @@ DEFPY(ip_msdp_timers, ip_msdp_timers_cmd,
nb_cli_enqueue_change(vty, "./connection-retry", NB_OP_DESTROY,
NULL);
- nb_cli_apply_changes(vty, xpath);
-
+ nb_cli_apply_changes(vty, FRR_PIM_MSDP_XPATH, "frr-pim:pimd", "pim",
+ vrfname, "frr-routing:ipv4");
return CMD_SUCCESS;
}
@@ -4810,20 +4807,17 @@ DEFPY(no_ip_msdp_timers, no_ip_msdp_timers_cmd,
IGNORED_IN_NO_STR)
{
const char *vrfname;
- char xpath[XPATH_MAXLEN];
vrfname = pim_cli_get_vrf_name(vty);
if (vrfname == NULL)
return CMD_WARNING_CONFIG_FAILED;
- snprintf(xpath, sizeof(xpath), FRR_PIM_MSDP_XPATH, "frr-pim:pimd",
- "pim", vrfname, "frr-routing:ipv4");
-
nb_cli_enqueue_change(vty, "./hold-time", NB_OP_DESTROY, NULL);
nb_cli_enqueue_change(vty, "./keep-alive", NB_OP_DESTROY, NULL);
nb_cli_enqueue_change(vty, "./connection-retry", NB_OP_DESTROY, NULL);
- nb_cli_apply_changes(vty, xpath);
+ nb_cli_apply_changes(vty, FRR_PIM_MSDP_XPATH, "frr-pim:pimd", "pim",
+ vrfname, "frr-routing:ipv4");
return CMD_SUCCESS;
}
diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c
index 28e4c488f..d220ae082 100644
--- a/pimd/pim_cmd_common.c
+++ b/pimd/pim_cmd_common.c
@@ -299,7 +299,7 @@ int pim_process_no_rp_kat_cmd(struct vty *vty)
sizeof(rs_timer_xpath));
/* RFC4601 */
- v = yang_dnode_get_uint16(vty->candidate_config->dnode,
+ v = yang_dnode_get_uint16(vty->candidate_config->dnode, "%s",
rs_timer_xpath);
v = 3 * v + PIM_REGISTER_PROBE_TIME_DEFAULT;
if (v > UINT16_MAX)
@@ -688,7 +688,7 @@ int pim_process_no_rp_plist_cmd(struct vty *vty, const char *rp_str,
return NB_OK;
}
- plist = yang_dnode_get_string(plist_dnode, plist_xpath);
+ plist = yang_dnode_get_string(plist_dnode, "%s", plist_xpath);
if (strcmp(prefix_list, plist)) {
vty_out(vty, "%% Unable to find specified RP\n");
return NB_OK;
diff --git a/staticd/static_vty.c b/staticd/static_vty.c
index ff7962203..c5bea755e 100644
--- a/staticd/static_vty.c
+++ b/staticd/static_vty.c
@@ -377,7 +377,7 @@ static int static_route_nb_run(struct vty *vty, struct static_route_args *args)
}
}
- ret = nb_cli_apply_changes(vty, xpath_prefix);
+ ret = nb_cli_apply_changes(vty, "%s", xpath_prefix);
} else {
if (args->source)
snprintf(ab_xpath, sizeof(ab_xpath),
@@ -411,7 +411,7 @@ static int static_route_nb_run(struct vty *vty, struct static_route_args *args)
yang_dnode_get_path(dnode, ab_xpath, XPATH_MAXLEN);
nb_cli_enqueue_change(vty, ab_xpath, NB_OP_DESTROY, NULL);
- ret = nb_cli_apply_changes(vty, ab_xpath);
+ ret = nb_cli_apply_changes(vty, "%s", ab_xpath);
}
return ret;