mirror of
				https://git.proxmox.com/git/mirror_frr
				synced 2025-10-31 04:57:38 +00:00 
			
		
		
		
	Merge pull request #12695 from opensourcerouting/format-warnings
build: `-Wformat-nonliteral -Wformat-security`
This commit is contained in:
		
						commit
						ea768492f1
					
				| @ -746,6 +746,7 @@ static void bfd_sd_reschedule(struct bfd_vrf_global *bvrf, int sd) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| PRINTFRR(6, 7) | ||||
| static void cp_debug(bool mhop, struct sockaddr_any *peer, | ||||
| 		     struct sockaddr_any *local, ifindex_t ifindex, | ||||
| 		     vrf_id_t vrfid, const char *fmt, ...) | ||||
| @ -844,7 +845,7 @@ void bfd_recv_cb(struct thread *t) | ||||
| 	/* Implement RFC 5880 6.8.6 */ | ||||
| 	if (mlen < BFD_PKT_LEN) { | ||||
| 		cp_debug(is_mhop, &peer, &local, ifindex, vrfid, | ||||
| 			 "too small (%ld bytes)", mlen); | ||||
| 			 "too small (%zd bytes)", mlen); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
|  | ||||
| @ -81,6 +81,7 @@ static void bfdd_client_deregister(struct stream *msg); | ||||
| /*
 | ||||
|  * Functions | ||||
|  */ | ||||
| PRINTFRR(2, 3) | ||||
| static void debug_printbpc(const struct bfd_peer_cfg *bpc, const char *fmt, ...) | ||||
| { | ||||
| 	char timers[3][128] = {}; | ||||
|  | ||||
| @ -2122,16 +2122,12 @@ const char *aspath_print(struct aspath *as) | ||||
| } | ||||
| 
 | ||||
| /* Printing functions */ | ||||
| /* Feed the AS_PATH to the vty; the suffix string follows it only in case
 | ||||
| /* Feed the AS_PATH to the vty; the space suffix follows it only in case
 | ||||
|  * AS_PATH wasn't empty. | ||||
|  */ | ||||
| void aspath_print_vty(struct vty *vty, const char *format, struct aspath *as, | ||||
| 		      const char *suffix) | ||||
| void aspath_print_vty(struct vty *vty, struct aspath *as) | ||||
| { | ||||
| 	assert(format); | ||||
| 	vty_out(vty, format, as->str); | ||||
| 	if (as->str_len && strlen(suffix)) | ||||
| 		vty_out(vty, "%s", suffix); | ||||
| 	vty_out(vty, "%s%s", as->str, as->str_len ? " " : ""); | ||||
| } | ||||
| 
 | ||||
| static void aspath_show_all_iterator(struct hash_bucket *bucket, | ||||
|  | ||||
| @ -104,8 +104,7 @@ extern void aspath_free(struct aspath *aspath); | ||||
| extern struct aspath *aspath_intern(struct aspath *aspath); | ||||
| extern void aspath_unintern(struct aspath **aspath); | ||||
| extern const char *aspath_print(struct aspath *aspath); | ||||
| extern void aspath_print_vty(struct vty *vty, const char *format, | ||||
| 			     struct aspath *aspath, const char *suffix); | ||||
| extern void aspath_print_vty(struct vty *vty, struct aspath *aspath); | ||||
| extern void aspath_print_all_vty(struct vty *vty); | ||||
| extern unsigned int aspath_key_make(const void *p); | ||||
| extern unsigned int aspath_get_first_as(struct aspath *aspath); | ||||
|  | ||||
| @ -117,9 +117,13 @@ static FILE *bgp_dump_open_file(struct bgp_dump *bgp_dump) | ||||
| 	if (bgp_dump->filename[0] != DIRECTORY_SEP) { | ||||
| 		snprintf(fullpath, sizeof(fullpath), "%s/%s", vty_get_cwd(), | ||||
| 			 bgp_dump->filename); | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| 		/* user supplied date/time format string */ | ||||
| 		ret = strftime(realpath, MAXPATHLEN, fullpath, &tm); | ||||
| 	} else | ||||
| 		ret = strftime(realpath, MAXPATHLEN, bgp_dump->filename, &tm); | ||||
| #pragma GCC diagnostic pop | ||||
| 
 | ||||
| 	if (ret == 0) { | ||||
| 		flog_warn(EC_BGP_DUMP, "%s: strftime error", __func__); | ||||
|  | ||||
| @ -9453,7 +9453,7 @@ void route_vty_out(struct vty *vty, const struct prefix *p, | ||||
| 			json_object_string_add(json_path, "path", | ||||
| 					       attr->aspath->str); | ||||
| 		else | ||||
| 			aspath_print_vty(vty, "%s", attr->aspath, " "); | ||||
| 			aspath_print_vty(vty, attr->aspath); | ||||
| 	} | ||||
| 
 | ||||
| 	/* Print origin */ | ||||
| @ -9671,7 +9671,7 @@ CPP_NOTICE("Drop `bgpOriginCodes` from JSON outputs") | ||||
| 
 | ||||
| 			/* Print aspath */ | ||||
| 			if (attr->aspath) | ||||
| 				aspath_print_vty(vty, "%s", attr->aspath, " "); | ||||
| 				aspath_print_vty(vty, attr->aspath); | ||||
| 
 | ||||
| 			/* Print origin */ | ||||
| 			vty_out(vty, "%s", bgp_origin_str[attr->origin]); | ||||
| @ -9938,7 +9938,7 @@ static void damp_route_vty_out(struct vty *vty, const struct prefix *p, | ||||
| 						use_json, NULL)); | ||||
| 
 | ||||
| 		if (attr->aspath) | ||||
| 			aspath_print_vty(vty, "%s", attr->aspath, " "); | ||||
| 			aspath_print_vty(vty, attr->aspath); | ||||
| 
 | ||||
| 		vty_out(vty, "%s", bgp_origin_str[attr->origin]); | ||||
| 
 | ||||
| @ -10015,7 +10015,7 @@ static void flap_route_vty_out(struct vty *vty, const struct prefix *p, | ||||
| 			vty_out(vty, "%*s ", 8, " "); | ||||
| 
 | ||||
| 		if (attr->aspath) | ||||
| 			aspath_print_vty(vty, "%s", attr->aspath, " "); | ||||
| 			aspath_print_vty(vty, attr->aspath); | ||||
| 
 | ||||
| 		vty_out(vty, "%s", bgp_origin_str[attr->origin]); | ||||
| 
 | ||||
| @ -10299,7 +10299,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn, | ||||
| 					       attr->aspath->json); | ||||
| 		} else { | ||||
| 			if (attr->aspath->segments) | ||||
| 				aspath_print_vty(vty, "  %s", attr->aspath, ""); | ||||
| 				vty_out(vty, "  %s", attr->aspath->str); | ||||
| 			else | ||||
| 				vty_out(vty, "  Local"); | ||||
| 		} | ||||
|  | ||||
| @ -12002,7 +12002,7 @@ static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty *vty, | ||||
| 	if (json) | ||||
| 		json_object_string_add(json, "remoteGrMode", mode); | ||||
| 	else | ||||
| 		vty_out(vty, mode, "\n"); | ||||
| 		vty_out(vty, "%s\n", mode); | ||||
| } | ||||
| 
 | ||||
| static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, | ||||
| @ -12034,7 +12034,7 @@ static void bgp_show_neighbor_graceful_restart_local_mode(struct vty *vty, | ||||
| 	if (json) | ||||
| 		json_object_string_add(json, "localGrMode", mode); | ||||
| 	else | ||||
| 		vty_out(vty, mode, "\n"); | ||||
| 		vty_out(vty, "%s\n", mode); | ||||
| } | ||||
| 
 | ||||
| static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi( | ||||
|  | ||||
| @ -322,6 +322,7 @@ int rfapiDebugPrintf(void *dummy, const char *format, ...) | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| PRINTFRR(2, 3) | ||||
| static int rfapiStdioPrintf(void *stream, const char *format, ...) | ||||
| { | ||||
| 	FILE *file = NULL; | ||||
|  | ||||
| @ -349,6 +349,8 @@ AC_C_FLAG([-fno-omit-frame-pointer]) | ||||
| AC_C_FLAG([-funwind-tables]) | ||||
| AC_C_FLAG([-Wall]) | ||||
| AC_C_FLAG([-Wextra]) | ||||
| AC_C_FLAG([-Wformat-nonliteral]) | ||||
| AC_C_FLAG([-Wformat-security]) | ||||
| AC_C_FLAG([-Wstrict-prototypes]) | ||||
| AC_C_FLAG([-Wmissing-prototypes]) | ||||
| AC_C_FLAG([-Wmissing-declarations]) | ||||
|  | ||||
| @ -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, | ||||
|  | ||||
| @ -77,7 +77,11 @@ log_warn(const char *emsg, ...) | ||||
| 			vlog(LOG_ERR, emsg, ap); | ||||
| 			logit(LOG_ERR, "%s", strerror(errno)); | ||||
| 		} else { | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| 			/* format extended above */ | ||||
| 			vlog(LOG_ERR, nfmt, ap); | ||||
| #pragma GCC diagnostic pop | ||||
| 			free(nfmt); | ||||
| 		} | ||||
| 		va_end(ap); | ||||
|  | ||||
| @ -108,6 +108,7 @@ int main(int argc, char **argv) | ||||
| 
 | ||||
| #include "log.h" | ||||
| 
 | ||||
| PRINTFRR(3, 0) | ||||
| void vzlogx(const struct xref_logmsg *xref, int prio, | ||||
| 	    const char *format, va_list args) | ||||
| { | ||||
|  | ||||
| @ -219,6 +219,7 @@ ferr_r ferr_clear(void) | ||||
| 	return ferr_ok(); | ||||
| } | ||||
| 
 | ||||
| PRINTFRR(7, 0) | ||||
| static ferr_r ferr_set_va(const char *file, int line, const char *func, | ||||
| 			  enum ferr_kind kind, const char *pathname, | ||||
| 			  int errno_val, const char *text, va_list va) | ||||
|  | ||||
| @ -178,10 +178,12 @@ ferr_r ferr_clear(void); | ||||
| 
 | ||||
| /* do NOT call these functions directly.  only for macro use! */ | ||||
| ferr_r ferr_set_internal(const char *file, int line, const char *func, | ||||
| 			 enum ferr_kind kind, const char *text, ...); | ||||
| 			 enum ferr_kind kind, const char *text, ...) | ||||
| 	PRINTFRR(5, 6); | ||||
| ferr_r ferr_set_internal_ext(const char *file, int line, const char *func, | ||||
| 			     enum ferr_kind kind, const char *pathname, | ||||
| 			     int errno_val, const char *text, ...); | ||||
| 			     int errno_val, const char *text, ...) | ||||
| 	PRINTFRR(7, 8); | ||||
| 
 | ||||
| #define ferr_ok() 0 | ||||
| 
 | ||||
| @ -221,7 +223,8 @@ ferr_r ferr_set_internal_ext(const char *file, int line, const char *func, | ||||
| 
 | ||||
| #include "vty.h" | ||||
| /* print error message to vty;  $ERR is replaced by the error's message */ | ||||
| void vty_print_error(struct vty *vty, ferr_r err, const char *msg, ...); | ||||
| void vty_print_error(struct vty *vty, ferr_r err, const char *msg, ...) | ||||
| 	PRINTFRR(3, 4); | ||||
| 
 | ||||
| #define CMD_FERR_DO(func, action, ...)                                         \ | ||||
| 	do {                                                                   \ | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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++; | ||||
| 	} | ||||
|  | ||||
							
								
								
									
										4
									
								
								lib/if.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								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) | ||||
|  | ||||
| @ -71,7 +71,8 @@ extern void nb_cli_enqueue_change(struct vty *vty, const char *xpath, | ||||
|  *    CMD_SUCCESS on success, CMD_WARNING_CONFIG_FAILED otherwise. | ||||
|  */ | ||||
| extern int nb_cli_apply_changes_clear_pending(struct vty *vty, | ||||
| 					      const char *xpath_base_fmt, ...); | ||||
| 					      const char *xpath_base_fmt, ...) | ||||
| 	PRINTFRR(2, 3); | ||||
| 
 | ||||
| /*
 | ||||
|  * Apply enqueued changes to the candidate configuration, this function | ||||
| @ -89,7 +90,7 @@ extern int nb_cli_apply_changes_clear_pending(struct vty *vty, | ||||
|  *    CMD_SUCCESS on success, CMD_WARNING_CONFIG_FAILED otherwise. | ||||
|  */ | ||||
| extern int nb_cli_apply_changes(struct vty *vty, const char *xpath_base_fmt, | ||||
| 				...); | ||||
| 				...) PRINTFRR(2, 3); | ||||
| 
 | ||||
| /*
 | ||||
|  * Execute a YANG RPC or Action. | ||||
|  | ||||
| @ -293,5 +293,9 @@ static ssize_t printfrr_va(struct fbuf *buf, struct printfrr_eargs *ea, | ||||
| 	 * when allocating a larger buffer in asnprintfrr() | ||||
| 	 */ | ||||
| 	va_copy(ap, *vaf->va); | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| 	/* can't format check this */ | ||||
| 	return vbprintfrr(buf, vaf->fmt, ap); | ||||
| #pragma GCC diagnostic pop | ||||
| } | ||||
|  | ||||
| @ -504,14 +504,20 @@ reswitch:	switch (ch) { | ||||
| 				fmt[4] = ch; | ||||
| 				fmt[5] = '\0'; | ||||
| 
 | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| 				snprintf(buf, sizeof(buf), fmt, prec, arg); | ||||
| #pragma GCC diagnostic pop | ||||
| 			} else { | ||||
| 				double arg = GETARG(double); | ||||
| 				char fmt[5] = "%.*"; | ||||
| 				fmt[3] = ch; | ||||
| 				fmt[4] = '\0'; | ||||
| 
 | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| 				snprintf(buf, sizeof(buf), fmt, prec, arg); | ||||
| #pragma GCC diagnostic pop | ||||
| 			} | ||||
| 			cp = buf; | ||||
| 			/* for proper padding */ | ||||
|  | ||||
| @ -130,6 +130,7 @@ struct ttable *ttable_new(const struct ttable_style *style) | ||||
|  * | ||||
|  * @return pointer to the first cell of allocated row | ||||
|  */ | ||||
| PRINTFRR(3, 0) | ||||
| static struct ttable_cell *ttable_insert_row_va(struct ttable *tt, int i, | ||||
| 						const char *format, va_list ap) | ||||
| { | ||||
| @ -435,13 +436,12 @@ char *ttable_dump(struct ttable *tt, const char *newline) | ||||
| 				abspad -= row[j].style.border.right_on ? 1 : 0; | ||||
| 
 | ||||
| 			/* print text */ | ||||
| 			const char *fmt; | ||||
| 			if (row[j].style.align == LEFT) | ||||
| 				fmt = "%-*s"; | ||||
| 				pos += sprintf(&buf[pos], "%-*s", abspad, | ||||
| 					       row[j].text); | ||||
| 			else | ||||
| 				fmt = "%*s"; | ||||
| 
 | ||||
| 			pos += sprintf(&buf[pos], fmt, abspad, row[j].text); | ||||
| 				pos += sprintf(&buf[pos], "%*s", abspad, | ||||
| 					       row[j].text); | ||||
| 
 | ||||
| 			/* print right padding */ | ||||
| 			for (int k = 0; k < row[j].style.rpad; k++) | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
							
								
								
									
										14
									
								
								lib/vty.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								lib/vty.c
									
									
									
									
									
								
							| @ -343,6 +343,15 @@ void vty_hello(struct vty *vty) | ||||
| 		vty_out(vty, "%s", host.motd); | ||||
| } | ||||
| 
 | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| /* prompt formatting has a %s in the cmd_node prompt string.
 | ||||
|  * | ||||
|  * Also for some reason GCC emits the warning on the end of the function | ||||
|  * (optimization maybe?) rather than on the vty_out line, so this pragma | ||||
|  * wraps the entire function rather than just the vty_out line. | ||||
|  */ | ||||
| 
 | ||||
| /* Put out prompt and wait input from user. */ | ||||
| static void vty_prompt(struct vty *vty) | ||||
| { | ||||
| @ -350,6 +359,7 @@ static void vty_prompt(struct vty *vty) | ||||
| 		vty_out(vty, cmd_prompt(vty->node), cmd_hostname_get()); | ||||
| 	} | ||||
| } | ||||
| #pragma GCC diagnostic pop | ||||
| 
 | ||||
| /* Send WILL TELOPT_ECHO to remote server. */ | ||||
| static void vty_will_echo(struct vty *vty) | ||||
| @ -464,8 +474,12 @@ static int vty_command(struct vty *vty, char *buf) | ||||
| 			 vty->address); | ||||
| 
 | ||||
| 		/* format the prompt */ | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| 		/* prompt formatting has a %s in the cmd_node prompt string */ | ||||
| 		snprintf(prompt_str, sizeof(prompt_str), cmd_prompt(vty->node), | ||||
| 			 vty_str); | ||||
| #pragma GCC diagnostic pop | ||||
| 
 | ||||
| 		/* now log the command */ | ||||
| 		zlog_notice("%s%s", prompt_str, buf); | ||||
|  | ||||
							
								
								
									
										15
									
								
								lib/yang.h
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								lib/yang.h
									
									
									
									
									
								
							| @ -331,7 +331,8 @@ extern void yang_dnode_get_path(const struct lyd_node *dnode, char *xpath, | ||||
|  *    Schema name of the libyang data node. | ||||
|  */ | ||||
| extern const char *yang_dnode_get_schema_name(const struct lyd_node *dnode, | ||||
| 					      const char *xpath_fmt, ...); | ||||
| 					      const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(2, 3); | ||||
| 
 | ||||
| /*
 | ||||
|  * Find a libyang data node by its YANG data path. | ||||
| @ -366,7 +367,8 @@ extern struct lyd_node *yang_dnode_get(const struct lyd_node *dnode, | ||||
|  *    The libyang data node if found, or NULL if not found. | ||||
|  */ | ||||
| extern struct lyd_node *yang_dnode_getf(const struct lyd_node *dnode, | ||||
| 					const char *path_fmt, ...); | ||||
| 					const char *path_fmt, ...) | ||||
| 	PRINTFRR(2, 3); | ||||
| 
 | ||||
| /*
 | ||||
|  * Check if a libyang data node exists. | ||||
| @ -400,7 +402,7 @@ extern bool yang_dnode_exists(const struct lyd_node *dnode, const char *xpath); | ||||
|  *    true if a libyang data node was found, false otherwise. | ||||
|  */ | ||||
| extern bool yang_dnode_existsf(const struct lyd_node *dnode, | ||||
| 			       const char *xpath_fmt, ...); | ||||
| 			       const char *xpath_fmt, ...) PRINTFRR(2, 3); | ||||
| 
 | ||||
| /*
 | ||||
|  * Iterate over all libyang data nodes that satisfy an XPath query. | ||||
| @ -422,7 +424,7 @@ extern bool yang_dnode_existsf(const struct lyd_node *dnode, | ||||
|  */ | ||||
| void yang_dnode_iterate(yang_dnode_iter_cb cb, void *arg, | ||||
| 			const struct lyd_node *dnode, const char *xpath_fmt, | ||||
| 			...); | ||||
| 			...) PRINTFRR(4, 5); | ||||
| 
 | ||||
| /*
 | ||||
|  * Check if the libyang data node contains a default value. Non-presence | ||||
| @ -459,7 +461,7 @@ extern bool yang_dnode_is_default(const struct lyd_node *dnode, | ||||
|  *    true if the data node contains the default value, false otherwise. | ||||
|  */ | ||||
| extern bool yang_dnode_is_defaultf(const struct lyd_node *dnode, | ||||
| 				   const char *xpath_fmt, ...); | ||||
| 				   const char *xpath_fmt, ...) PRINTFRR(2, 3); | ||||
| 
 | ||||
| /*
 | ||||
|  * Check if the libyang data node and all of its children contain default | ||||
| @ -566,7 +568,8 @@ extern struct list *yang_data_list_new(void); | ||||
|  *    Pointer to yang_data if found, NULL otherwise. | ||||
|  */ | ||||
| extern struct yang_data *yang_data_list_find(const struct list *list, | ||||
| 					     const char *xpath_fmt, ...); | ||||
| 					     const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(2, 3); | ||||
| 
 | ||||
| /*
 | ||||
|  * Create and set up a libyang context (for use by the translator) | ||||
|  | ||||
| @ -339,8 +339,12 @@ yang_translate_xpath(const struct yang_translator *translator, int dir, | ||||
| 	if (!mapping) | ||||
| 		return YANG_TRANSLATE_NOTFOUND; | ||||
| 
 | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| 	/* processing format strings from mapping node... */ | ||||
| 	n = sscanf(xpath, mapping->xpath_from_fmt, keys[0], keys[1], keys[2], | ||||
| 		   keys[3]); | ||||
| #pragma GCC diagnostic pop | ||||
| 	if (n < 0) { | ||||
| 		flog_warn(EC_LIB_YANG_TRANSLATION_ERROR, | ||||
| 			  "%s: sscanf() failed: %s", __func__, | ||||
| @ -348,8 +352,12 @@ yang_translate_xpath(const struct yang_translator *translator, int dir, | ||||
| 		return YANG_TRANSLATE_FAILURE; | ||||
| 	} | ||||
| 
 | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| 	/* processing format strings from mapping node... */ | ||||
| 	snprintf(xpath, xpath_len, mapping->xpath_to_fmt, keys[0], keys[1], | ||||
| 		 keys[2], keys[3]); | ||||
| #pragma GCC diagnostic pop | ||||
| 
 | ||||
| 	return YANG_TRANSLATE_SUCCESS; | ||||
| } | ||||
|  | ||||
| @ -58,6 +58,7 @@ | ||||
| 		}                                                              \ | ||||
| 	} while (0) | ||||
| 
 | ||||
| PRINTFRR(2, 0) | ||||
| static inline const char * | ||||
| yang_dnode_xpath_get_canon(const struct lyd_node *dnode, const char *xpath_fmt, | ||||
| 			   va_list ap) | ||||
| @ -75,6 +76,7 @@ yang_dnode_xpath_get_canon(const struct lyd_node *dnode, const char *xpath_fmt, | ||||
| 	return lyd_get_value(&__dleaf->node); | ||||
| } | ||||
| 
 | ||||
| PRINTFRR(2, 0) | ||||
| static inline const struct lyd_value * | ||||
| yang_dnode_xpath_get_value(const struct lyd_node *dnode, const char *xpath_fmt, | ||||
| 			   va_list ap) | ||||
|  | ||||
| @ -30,105 +30,120 @@ extern "C" { | ||||
| extern bool yang_str2bool(const char *value); | ||||
| extern struct yang_data *yang_data_new_bool(const char *xpath, bool value); | ||||
| extern bool yang_dnode_get_bool(const struct lyd_node *dnode, | ||||
| 				const char *xpath_fmt, ...); | ||||
| extern bool yang_get_default_bool(const char *xpath_fmt, ...); | ||||
| 				const char *xpath_fmt, ...) PRINTFRR(2, 3); | ||||
| extern bool yang_get_default_bool(const char *xpath_fmt, ...) PRINTFRR(1, 2); | ||||
| 
 | ||||
| /* dec64 */ | ||||
| extern double yang_str2dec64(const char *xpath, const char *value); | ||||
| extern struct yang_data *yang_data_new_dec64(const char *xpath, double value); | ||||
| extern double yang_dnode_get_dec64(const struct lyd_node *dnode, | ||||
| 				   const char *xpath_fmt, ...); | ||||
| extern double yang_get_default_dec64(const char *xpath_fmt, ...); | ||||
| 				   const char *xpath_fmt, ...) PRINTFRR(2, 3); | ||||
| extern double yang_get_default_dec64(const char *xpath_fmt, ...) PRINTFRR(1, 2); | ||||
| 
 | ||||
| /* enum */ | ||||
| extern int yang_str2enum(const char *xpath, const char *value); | ||||
| extern struct yang_data *yang_data_new_enum(const char *xpath, int value); | ||||
| extern int yang_dnode_get_enum(const struct lyd_node *dnode, | ||||
| 			       const char *xpath_fmt, ...); | ||||
| extern int yang_get_default_enum(const char *xpath_fmt, ...); | ||||
| 			       const char *xpath_fmt, ...) PRINTFRR(2, 3); | ||||
| extern int yang_get_default_enum(const char *xpath_fmt, ...) PRINTFRR(1, 2); | ||||
| 
 | ||||
| /* int8 */ | ||||
| extern int8_t yang_str2int8(const char *value); | ||||
| extern struct yang_data *yang_data_new_int8(const char *xpath, int8_t value); | ||||
| extern int8_t yang_dnode_get_int8(const struct lyd_node *dnode, | ||||
| 				  const char *xpath_fmt, ...); | ||||
| extern int8_t yang_get_default_int8(const char *xpath_fmt, ...); | ||||
| 				  const char *xpath_fmt, ...) PRINTFRR(2, 3); | ||||
| extern int8_t yang_get_default_int8(const char *xpath_fmt, ...) PRINTFRR(1, 2); | ||||
| 
 | ||||
| /* int16 */ | ||||
| extern int16_t yang_str2int16(const char *value); | ||||
| extern struct yang_data *yang_data_new_int16(const char *xpath, int16_t value); | ||||
| extern int16_t yang_dnode_get_int16(const struct lyd_node *dnode, | ||||
| 				    const char *xpath_fmt, ...); | ||||
| extern int16_t yang_get_default_int16(const char *xpath_fmt, ...); | ||||
| 				    const char *xpath_fmt, ...) PRINTFRR(2, 3); | ||||
| extern int16_t yang_get_default_int16(const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(1, 2); | ||||
| 
 | ||||
| /* int32 */ | ||||
| extern int32_t yang_str2int32(const char *value); | ||||
| extern struct yang_data *yang_data_new_int32(const char *xpath, int32_t value); | ||||
| extern int32_t yang_dnode_get_int32(const struct lyd_node *dnode, | ||||
| 				    const char *xpath_fmt, ...); | ||||
| extern int32_t yang_get_default_int32(const char *xpath_fmt, ...); | ||||
| 				    const char *xpath_fmt, ...) PRINTFRR(2, 3); | ||||
| extern int32_t yang_get_default_int32(const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(1, 2); | ||||
| 
 | ||||
| /* int64 */ | ||||
| extern int64_t yang_str2int64(const char *value); | ||||
| extern struct yang_data *yang_data_new_int64(const char *xpath, int64_t value); | ||||
| extern int64_t yang_dnode_get_int64(const struct lyd_node *dnode, | ||||
| 				    const char *xpath_fmt, ...); | ||||
| extern int64_t yang_get_default_int64(const char *xpath_fmt, ...); | ||||
| 				    const char *xpath_fmt, ...) PRINTFRR(2, 3); | ||||
| extern int64_t yang_get_default_int64(const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(1, 2); | ||||
| 
 | ||||
| /* uint8 */ | ||||
| extern uint8_t yang_str2uint8(const char *value); | ||||
| extern struct yang_data *yang_data_new_uint8(const char *xpath, uint8_t value); | ||||
| extern uint8_t yang_dnode_get_uint8(const struct lyd_node *dnode, | ||||
| 				    const char *xpath_fmt, ...); | ||||
| extern uint8_t yang_get_default_uint8(const char *xpath_fmt, ...); | ||||
| 				    const char *xpath_fmt, ...) PRINTFRR(2, 3); | ||||
| extern uint8_t yang_get_default_uint8(const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(1, 2); | ||||
| 
 | ||||
| /* uint16 */ | ||||
| extern uint16_t yang_str2uint16(const char *value); | ||||
| extern struct yang_data *yang_data_new_uint16(const char *xpath, | ||||
| 					      uint16_t value); | ||||
| extern uint16_t yang_dnode_get_uint16(const struct lyd_node *dnode, | ||||
| 				      const char *xpath_fmt, ...); | ||||
| extern uint16_t yang_get_default_uint16(const char *xpath_fmt, ...); | ||||
| 				      const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(2, 3); | ||||
| extern uint16_t yang_get_default_uint16(const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(1, 2); | ||||
| 
 | ||||
| /* uint32 */ | ||||
| extern uint32_t yang_str2uint32(const char *value); | ||||
| extern struct yang_data *yang_data_new_uint32(const char *xpath, | ||||
| 					      uint32_t value); | ||||
| extern uint32_t yang_dnode_get_uint32(const struct lyd_node *dnode, | ||||
| 				      const char *xpath_fmt, ...); | ||||
| extern uint32_t yang_get_default_uint32(const char *xpath_fmt, ...); | ||||
| 				      const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(2, 3); | ||||
| extern uint32_t yang_get_default_uint32(const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(1, 2); | ||||
| 
 | ||||
| /* uint64 */ | ||||
| extern uint64_t yang_str2uint64(const char *value); | ||||
| extern struct yang_data *yang_data_new_uint64(const char *xpath, | ||||
| 					      uint64_t value); | ||||
| extern uint64_t yang_dnode_get_uint64(const struct lyd_node *dnode, | ||||
| 				      const char *xpath_fmt, ...); | ||||
| extern uint64_t yang_get_default_uint64(const char *xpath_fmt, ...); | ||||
| 				      const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(2, 3); | ||||
| extern uint64_t yang_get_default_uint64(const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(1, 2); | ||||
| 
 | ||||
| /* string */ | ||||
| extern struct yang_data *yang_data_new_string(const char *xpath, | ||||
| 					      const char *value); | ||||
| extern const char *yang_dnode_get_string(const struct lyd_node *dnode, | ||||
| 					 const char *xpath_fmt, ...); | ||||
| 					 const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(2, 3); | ||||
| extern void yang_dnode_get_string_buf(char *buf, size_t size, | ||||
| 				      const struct lyd_node *dnode, | ||||
| 				      const char *xpath_fmt, ...); | ||||
| extern const char *yang_get_default_string(const char *xpath_fmt, ...); | ||||
| 				      const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(4, 5); | ||||
| extern const char *yang_get_default_string(const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(1, 2); | ||||
| extern void yang_get_default_string_buf(char *buf, size_t size, | ||||
| 					const char *xpath_fmt, ...); | ||||
| 					const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(3, 4); | ||||
| 
 | ||||
| /* binary */ | ||||
| extern struct yang_data *yang_data_new_binary(const char *xpath, | ||||
| 					      const char *value, size_t len); | ||||
| extern size_t yang_dnode_get_binary_buf(char *buf, size_t size, | ||||
| 					const struct lyd_node *dnode, | ||||
| 					const char *xpath_fmt, ...); | ||||
| 					const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(4, 5); | ||||
| 
 | ||||
| /* empty */ | ||||
| extern struct yang_data *yang_data_new_empty(const char *xpath); | ||||
| extern bool yang_dnode_get_empty(const struct lyd_node *dnode, | ||||
| 				 const char *xpath_fmt, ...); | ||||
| 				 const char *xpath_fmt, ...) PRINTFRR(2, 3); | ||||
| 
 | ||||
| /* ip prefix */ | ||||
| extern void yang_str2prefix(const char *value, union prefixptr prefix); | ||||
| @ -136,9 +151,9 @@ extern struct yang_data *yang_data_new_prefix(const char *xpath, | ||||
| 					      union prefixconstptr prefix); | ||||
| extern void yang_dnode_get_prefix(struct prefix *prefix, | ||||
| 				  const struct lyd_node *dnode, | ||||
| 				  const char *xpath_fmt, ...); | ||||
| 				  const char *xpath_fmt, ...) PRINTFRR(3, 4); | ||||
| extern void yang_get_default_prefix(union prefixptr var, const char *xpath_fmt, | ||||
| 				    ...); | ||||
| 				    ...) PRINTFRR(2, 3); | ||||
| 
 | ||||
| /* ipv4 */ | ||||
| extern void yang_str2ipv4(const char *value, struct in_addr *addr); | ||||
| @ -146,9 +161,9 @@ extern struct yang_data *yang_data_new_ipv4(const char *xpath, | ||||
| 					    const struct in_addr *addr); | ||||
| extern void yang_dnode_get_ipv4(struct in_addr *addr, | ||||
| 				const struct lyd_node *dnode, | ||||
| 				const char *xpath_fmt, ...); | ||||
| 				const char *xpath_fmt, ...) PRINTFRR(3, 4); | ||||
| extern void yang_get_default_ipv4(struct in_addr *var, const char *xpath_fmt, | ||||
| 				  ...); | ||||
| 				  ...) PRINTFRR(2, 3); | ||||
| 
 | ||||
| /* ipv4p */ | ||||
| extern void yang_str2ipv4p(const char *value, union prefixptr prefix); | ||||
| @ -156,9 +171,9 @@ extern struct yang_data *yang_data_new_ipv4p(const char *xpath, | ||||
| 					     union prefixconstptr prefix); | ||||
| extern void yang_dnode_get_ipv4p(union prefixptr prefix, | ||||
| 				 const struct lyd_node *dnode, | ||||
| 				 const char *xpath_fmt, ...); | ||||
| 				 const char *xpath_fmt, ...) PRINTFRR(3, 4); | ||||
| extern void yang_get_default_ipv4p(union prefixptr var, const char *xpath_fmt, | ||||
| 				   ...); | ||||
| 				   ...) PRINTFRR(2, 3); | ||||
| 
 | ||||
| /* ipv6 */ | ||||
| extern void yang_str2ipv6(const char *value, struct in6_addr *addr); | ||||
| @ -166,9 +181,9 @@ extern struct yang_data *yang_data_new_ipv6(const char *xpath, | ||||
| 					    const struct in6_addr *addr); | ||||
| extern void yang_dnode_get_ipv6(struct in6_addr *addr, | ||||
| 				const struct lyd_node *dnode, | ||||
| 				const char *xpath_fmt, ...); | ||||
| 				const char *xpath_fmt, ...) PRINTFRR(3, 4); | ||||
| extern void yang_get_default_ipv6(struct in6_addr *var, const char *xpath_fmt, | ||||
| 				  ...); | ||||
| 				  ...) PRINTFRR(2, 3); | ||||
| 
 | ||||
| /* ipv6p */ | ||||
| extern void yang_str2ipv6p(const char *value, union prefixptr prefix); | ||||
| @ -176,17 +191,18 @@ extern struct yang_data *yang_data_new_ipv6p(const char *xpath, | ||||
| 					     union prefixconstptr prefix); | ||||
| extern void yang_dnode_get_ipv6p(union prefixptr prefix, | ||||
| 				 const struct lyd_node *dnode, | ||||
| 				 const char *xpath_fmt, ...); | ||||
| 				 const char *xpath_fmt, ...) PRINTFRR(3, 4); | ||||
| extern void yang_get_default_ipv6p(union prefixptr var, const char *xpath_fmt, | ||||
| 				   ...); | ||||
| 				   ...) PRINTFRR(2, 3); | ||||
| 
 | ||||
| /* ip */ | ||||
| extern void yang_str2ip(const char *value, struct ipaddr *addr); | ||||
| extern struct yang_data *yang_data_new_ip(const char *xpath, | ||||
| 					  const struct ipaddr *addr); | ||||
| extern void yang_dnode_get_ip(struct ipaddr *addr, const struct lyd_node *dnode, | ||||
| 			      const char *xpath_fmt, ...); | ||||
| extern void yang_get_default_ip(struct ipaddr *var, const char *xpath_fmt, ...); | ||||
| 			      const char *xpath_fmt, ...) PRINTFRR(3, 4); | ||||
| extern void yang_get_default_ip(struct ipaddr *var, const char *xpath_fmt, ...) | ||||
| 	PRINTFRR(2, 3); | ||||
| 
 | ||||
| /* mac */ | ||||
| extern struct yang_data *yang_data_new_mac(const char *xpath, | ||||
|  | ||||
| @ -743,7 +743,11 @@ const char *zlog_msg_text(struct zlog_msg *msg, size_t *textlen) | ||||
| 		fb.outpos_i = 0; | ||||
| 
 | ||||
| 		va_copy(args, msg->args); | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| 		/* format-string checking is done further up the chain */ | ||||
| 		need += vbprintfrr(&fb, msg->fmt, args); | ||||
| #pragma GCC diagnostic pop | ||||
| 		va_end(args); | ||||
| 
 | ||||
| 		msg->textlen = need; | ||||
| @ -762,7 +766,11 @@ const char *zlog_msg_text(struct zlog_msg *msg, size_t *textlen) | ||||
| 			fb.outpos_i = 0; | ||||
| 
 | ||||
| 			va_copy(args, msg->args); | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| 			/* same as above */ | ||||
| 			vbprintfrr(&fb, msg->fmt, args); | ||||
| #pragma GCC diagnostic pop | ||||
| 			va_end(args); | ||||
| 
 | ||||
| 			bputch(&fb, '\n'); | ||||
|  | ||||
| @ -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); | ||||
| } | ||||
|  | ||||
| @ -38,7 +38,8 @@ DEFINE_MTYPE_STATIC(PATHD, PCEPLIB_MESSAGES, "PCEPlib PCEP Messages"); | ||||
| #define MAX_PATH_NAME_SIZE 255 | ||||
| 
 | ||||
| /* pceplib logging callback */ | ||||
| static int pceplib_logging_cb(int level, const char *fmt, va_list args); | ||||
| static int pceplib_logging_cb(int level, const char *fmt, va_list args) | ||||
| 	PRINTFRR(2, 0); | ||||
| 
 | ||||
| /* Socket callbacks */ | ||||
| static int pcep_lib_pceplib_socket_read_cb(void *fpt, void **thread, int fd, | ||||
|  | ||||
| @ -27,10 +27,12 @@ | ||||
| 
 | ||||
| #include <stdarg.h> | ||||
| #include <stdio.h> | ||||
| #include "compiler.h" | ||||
| #include "pcep_utils_logging.h" | ||||
| 
 | ||||
| /* Forward declaration */ | ||||
| int pcep_stdout_logger(int priority, const char *format, va_list args); | ||||
| int pcep_stdout_logger(int priority, const char *format, va_list args) | ||||
| 	PRINTFRR(2, 0); | ||||
| 
 | ||||
| static pcep_logger_func logger_func = pcep_stdout_logger; | ||||
| static int logging_level_ = LOG_INFO; | ||||
|  | ||||
| @ -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; | ||||
| } | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -2759,6 +2759,15 @@ static char *do_prepend(struct vty *vty, struct cmd_token **argv, int argc) | ||||
| 	return frrstr_join(argstr, argc + off, " "); | ||||
| } | ||||
| 
 | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| /* 'headline' is a format string with a %s for the daemon name
 | ||||
|  * | ||||
|  * Also for some reason GCC emits the warning on the end of the function | ||||
|  * (optimization maybe?) rather than on the vty_out line, so this pragma | ||||
|  * wraps the entire function rather than just the vty_out line. | ||||
|  */ | ||||
| 
 | ||||
| static int show_per_daemon(struct vty *vty, struct cmd_token **argv, int argc, | ||||
| 			   const char *headline) | ||||
| { | ||||
| @ -2777,6 +2786,7 @@ static int show_per_daemon(struct vty *vty, struct cmd_token **argv, int argc, | ||||
| 
 | ||||
| 	return ret; | ||||
| } | ||||
| #pragma GCC diagnostic pop | ||||
| 
 | ||||
| static int show_one_daemon(struct vty *vty, struct cmd_token **argv, int argc, | ||||
| 			   const char *name) | ||||
| @ -4353,7 +4363,11 @@ char *vtysh_prompt(void) | ||||
| { | ||||
| 	static char buf[512]; | ||||
| 
 | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| 	/* prompt formatting has a %s in the cmd_node prompt string. */ | ||||
| 	snprintf(buf, sizeof(buf), cmd_prompt(vty->node), cmd_hostname_get()); | ||||
| #pragma GCC diagnostic pop | ||||
| 	return buf; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -512,7 +512,11 @@ static int run_job(struct restart_info *restart, const char *cmdtype, | ||||
| 	restart->kills = 0; | ||||
| 	{ | ||||
| 		char cmd[strlen(command) + strlen(restart->name) + 1]; | ||||
| #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wformat-nonliteral" | ||||
| 		/* user supplied command string has a %s for the daemon name */ | ||||
| 		snprintf(cmd, sizeof(cmd), command, restart->name); | ||||
| #pragma GCC diagnostic pop | ||||
| 		if ((restart->pid = run_background(cmd)) > 0) { | ||||
| 			thread_add_timer(master, restart_kill, restart, | ||||
| 					 gs.restart_timeout, &restart->t_kill); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Donald Sharp
						Donald Sharp