diff options
| author | Stephen Worley <sworley@nvidia.com> | 2022-02-15 17:46:05 -0500 | 
|---|---|---|
| committer | Stephen Worley <sworley@nvidia.com> | 2022-03-09 18:02:44 -0500 | 
| commit | a3ea8493a8f173f96b84cc928c1ea25b1197ee52 (patch) | |
| tree | 45144f19c08c73ace943756740db50852e763fed /zebra/interface.c | |
| parent | 3db9f2db2bb44a459cd4bca93f4fc6b53b88adec (diff) | |
zebra: simplify reason code printing in show
Simplify the code for printing the reason codes via
show command. Just remove the trailing comma last
before printing.
Signed-off-by: Stephen Worley <sworley@nvidia.com>
Diffstat (limited to 'zebra/interface.c')
| -rw-r--r-- | zebra/interface.c | 52 | 
1 files changed, 17 insertions, 35 deletions
diff --git a/zebra/interface.c b/zebra/interface.c index 708e7b5485..97741bd404 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1852,49 +1852,31 @@ static void ifs_dump_brief_vty_json(json_object *json, struct vrf *vrf)  const char *zebra_protodown_rc_str(uint32_t protodown_rc, char *pd_buf,  				   uint32_t pd_buf_len)  { -	bool first = true; -  	pd_buf[0] = '\0'; +	size_t len;  	strlcat(pd_buf, "(", pd_buf_len); -	if (protodown_rc & ZEBRA_PROTODOWN_EXTERNAL) { -		if (first) -			first = false; -		else -			strlcat(pd_buf, ",", pd_buf_len); -		strlcat(pd_buf, "external", pd_buf_len); -	} +	if (protodown_rc & ZEBRA_PROTODOWN_EXTERNAL) +		strlcat(pd_buf, "external,", pd_buf_len); -	if (protodown_rc & ZEBRA_PROTODOWN_EVPN_STARTUP_DELAY) { -		if (first) -			first = false; -		else -			strlcat(pd_buf, ",", pd_buf_len); -		strlcat(pd_buf, "startup-delay", pd_buf_len); -	} +	if (protodown_rc & ZEBRA_PROTODOWN_EVPN_STARTUP_DELAY) +		strlcat(pd_buf, "startup-delay,", pd_buf_len); -	if (protodown_rc & ZEBRA_PROTODOWN_EVPN_UPLINK_DOWN) { -		if (first) -			first = false; -		else -			strlcat(pd_buf, ",", pd_buf_len); -		strlcat(pd_buf, "uplinks-down", pd_buf_len); -	} +	if (protodown_rc & ZEBRA_PROTODOWN_EVPN_UPLINK_DOWN) +		strlcat(pd_buf, "uplinks-down,", pd_buf_len); -	if (protodown_rc & ZEBRA_PROTODOWN_VRRP) { -		if (first) -			first = false; -		else -			strlcat(pd_buf, ",", pd_buf_len); -		strlcat(pd_buf, "vrrp", pd_buf_len); -	} +	if (protodown_rc & ZEBRA_PROTODOWN_VRRP) +		strlcat(pd_buf, "vrrp,", pd_buf_len); -	if (protodown_rc & ZEBRA_PROTODOWN_SHARP) { -		if (!first) -			strlcat(pd_buf, ",", pd_buf_len); -		strlcat(pd_buf, "sharp", pd_buf_len); -	} +	if (protodown_rc & ZEBRA_PROTODOWN_SHARP) +		strlcat(pd_buf, "sharp,", pd_buf_len); + +	len = strnlen(pd_buf, pd_buf_len); + +	/* Remove trailing comma */ +	if (pd_buf[len - 1] == ',') +		pd_buf[len - 1] = '\0';  	strlcat(pd_buf, ")", pd_buf_len);  | 
