@@ -1925,10 +1925,9 @@ static int __mask_bits(char *addr, size_t len)
return bits;
}
-static void flower_print_eth_addr(char *name, struct rtattr *addr_attr,
+static void flower_print_eth_addr(const char *name, struct rtattr *addr_attr,
struct rtattr *mask_attr)
{
- SPRINT_BUF(namefrm);
SPRINT_BUF(out);
SPRINT_BUF(b1);
size_t done;
@@ -1950,8 +1949,7 @@ static void flower_print_eth_addr(char *name, struct rtattr *addr_attr,
}
print_nl();
- sprintf(namefrm, " %s %%s", name);
- print_string(PRINT_ANY, name, namefrm, out);
+ print_string_name_value(name, out);
}
static void flower_print_eth_type(__be16 *p_eth_type,
@@ -2064,7 +2062,6 @@ static void flower_print_ip_addr(char *name, __be16 eth_type,
{
struct rtattr *addr_attr;
struct rtattr *mask_attr;
- SPRINT_BUF(namefrm);
SPRINT_BUF(out);
size_t done;
int family;
@@ -2096,9 +2093,9 @@ static void flower_print_ip_addr(char *name, __be16 eth_type,
sprintf(out + done, "/%d", bits);
print_nl();
- sprintf(namefrm, " %s %%s", name);
- print_string(PRINT_ANY, name, namefrm, out);
+ print_string_name_value(name, out);
}
+
static void flower_print_ip4_addr(char *name, struct rtattr *addr_attr,
struct rtattr *mask_attr)
{
@@ -2124,22 +2121,19 @@ static void flower_print_port_range(char *name, struct rtattr *min_attr,
print_hu(PRINT_JSON, "end", NULL, rta_getattr_be16(max_attr));
close_json_object();
} else {
- SPRINT_BUF(namefrm);
SPRINT_BUF(out);
size_t done;
done = sprintf(out, "%u", rta_getattr_be16(min_attr));
sprintf(out + done, "-%u", rta_getattr_be16(max_attr));
print_nl();
- sprintf(namefrm, " %s %%s", name);
- print_string(PRINT_ANY, name, namefrm, out);
+ print_string_name_value(name, out);
}
}
static void flower_print_tcp_flags(const char *name, struct rtattr *flags_attr,
struct rtattr *mask_attr)
{
- SPRINT_BUF(namefrm);
SPRINT_BUF(out);
size_t done;
@@ -2151,8 +2145,7 @@ static void flower_print_tcp_flags(const char *name, struct rtattr *flags_attr,
sprintf(out + done, "/%x", rta_getattr_be16(mask_attr));
print_nl();
- sprintf(namefrm, " %s %%s", name);
- print_string(PRINT_ANY, name, namefrm, out);
+ print_string_name_value(name, out);
}
static void flower_print_ct_state(struct rtattr *flags_attr,
@@ -2239,14 +2232,11 @@ static void flower_print_ct_mark(struct rtattr *attr,
static void flower_print_key_id(const char *name, struct rtattr *attr)
{
- SPRINT_BUF(namefrm);
-
if (!attr)
return;
print_nl();
- sprintf(namefrm, " %s %%u", name);
- print_uint(PRINT_ANY, name, namefrm, rta_getattr_be32(attr));
+ print_uint_name_value(name, rta_getattr_be32(attr));
}
static void flower_print_geneve_opts(const char *name, struct rtattr *attr,
@@ -2342,8 +2332,9 @@ static void flower_print_erspan_opts(const char *name, struct rtattr *attr,
sprintf(strbuf, "%u:%u:%u:%u", ver, idx, dir, hwid);
}
-static void flower_print_enc_parts(const char *name, const char *namefrm,
- struct rtattr *attr, char *key, char *mask)
+static void __attribute__((format(printf, 2, 0)))
+flower_print_enc_parts(const char *name, const char *namefrm,
+ struct rtattr *attr, char *key, char *mask)
{
char *key_token, *mask_token, *out;
int len;
@@ -2431,7 +2422,6 @@ static void flower_print_masked_u8(const char *name, struct rtattr *attr,
{
const char *value_str = NULL;
__u8 value, mask;
- SPRINT_BUF(namefrm);
SPRINT_BUF(out);
size_t done;
@@ -2452,8 +2442,7 @@ static void flower_print_masked_u8(const char *name, struct rtattr *attr,
sprintf(out + done, "/%d", mask);
print_nl();
- sprintf(namefrm, " %s %%s", name);
- print_string(PRINT_ANY, name, namefrm, out);
+ print_string_name_value(name, out);
}
static void flower_print_u8(const char *name, struct rtattr *attr)
@@ -2463,14 +2452,11 @@ static void flower_print_u8(const char *name, struct rtattr *attr)
static void flower_print_u32(const char *name, struct rtattr *attr)
{
- SPRINT_BUF(namefrm);
-
if (!attr)
return;
print_nl();
- sprintf(namefrm, " %s %%u", name);
- print_uint(PRINT_ANY, name, namefrm, rta_getattr_u32(attr));
+ print_uint_name_value(name, rta_getattr_u32(attr));
}
static void flower_print_mpls_opt_lse(struct rtattr *lse)
Clang complains about passing non-format string to print_string. Handle this by splitting json and non-json parts. Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com> --- tc/f_flower.c | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-)