*: 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>
This commit is contained in:
David Lamparter 2023-01-26 14:56:04 +01:00
parent c84e518709
commit ae08de9f42
9 changed files with 36 additions and 41 deletions

View File

@ -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,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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