diff options
author | Benjamin Poirier <bpoirier@nvidia.com> | 2023-12-11 09:07:18 -0500 |
---|---|---|
committer | Stephen Hemminger <stephen@networkplumber.org> | 2023-12-22 09:54:23 -0800 |
commit | cf7b528a21f67d5ef1ef1d9943bddc325255f6a4 (patch) | |
tree | ce80c8d1e0cd733126872956d9454564fc1dab03 | |
parent | 58c8a08175586d325368d4c483a8b755ace7dfaa (diff) | |
download | iproute2-cf7b528a21f67d5ef1ef1d9943bddc325255f6a4.tar.gz |
bridge: vlan: Use printf() to avoid temporary buffer
Currently, print_vlan_tunnel_info() is first outputting a formatted string
to a temporary buffer in order to use print_string() which can handle json
or normal text mode. Since this specific string is only output in normal
text mode, by calling printf() directly, we can avoid the need to first
output to a temporary string buffer.
Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
-rw-r--r-- | bridge/vlan.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/bridge/vlan.c b/bridge/vlan.c index dfc62f83a..797b7802a 100644 --- a/bridge/vlan.c +++ b/bridge/vlan.c @@ -662,11 +662,8 @@ static void print_vlan_tunnel_info(struct rtattr *tb, int ifindex) open_json_object(NULL); width = print_range("vlan", last_vid_start, tunnel_vid); if (width <= VLAN_ID_LEN) { - char buf[VLAN_ID_LEN + 1]; - - snprintf(buf, sizeof(buf), "%-*s", - VLAN_ID_LEN - width, ""); - print_string(PRINT_FP, NULL, "%s ", buf); + if (!is_json_context()) + printf("%-*s ", VLAN_ID_LEN - width, ""); } else { fprintf(stderr, "BUG: vlan range too wide, %u\n", width); |