Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH iproute2-next 00/11] Clang warning fixes
@ 2022-01-08 20:46 Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 01/11] tc: add format attribute to tc_print_rate Stephen Hemminger
` (11 more replies)
0 siblings, 12 replies; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-08 20:46 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
Building iproute2-next generates a lot of warnings and
finds a few bugs. This patchset resolves many of these
warnings but some areas (BPF, RDMA, DCB) need more work.
Stephen Hemminger (11):
tc: add format attribute to tc_print_rate
utils: add format attribute
netem: fix clang warnings
m_vlan: fix formatting of push ethernet src mac
flower: fix clang warnings
nexthop: fix clang warning about timer check
tc_util: fix clang warning in print_masked_type
ipl2tp: fix clang warning
can: fix clang warning
tipc: fix clang warning about empty format string
tunnel: fix clang warning
include/utils.h | 4 +++-
ip/ipl2tp.c | 5 ++--
ip/iplink_can.c | 5 ++--
ip/ipnexthop.c | 10 ++++----
ip/tunnel.c | 6 ++---
tc/f_flower.c | 62 +++++++++++++++++++++++--------------------------
tc/m_vlan.c | 4 ++--
tc/q_netem.c | 33 +++++++++++++++-----------
tc/tc_util.c | 21 +++++++----------
tipc/link.c | 2 +-
10 files changed, 77 insertions(+), 75 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH iproute2-next 01/11] tc: add format attribute to tc_print_rate
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
@ 2022-01-08 20:46 ` Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 02/11] utils: add format attribute Stephen Hemminger
` (10 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-08 20:46 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
From: Stephen Hemminger <stephen@networkplumber.org>
This catches future errors and silences warning from Clang.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/tc_util.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 48065897cee7..6d5eb754831a 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -247,7 +247,8 @@ int get_percent_rate64(__u64 *rate, const char *str, const char *dev)
return get_rate64(rate, r_str);
}
-void tc_print_rate(enum output_type t, const char *key, const char *fmt,
+void __attribute__((format(printf, 3, 0)))
+tc_print_rate(enum output_type t, const char *key, const char *fmt,
unsigned long long rate)
{
print_rate(use_iec, t, key, fmt, rate);
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH iproute2-next 02/11] utils: add format attribute
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 01/11] tc: add format attribute to tc_print_rate Stephen Hemminger
@ 2022-01-08 20:46 ` Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 03/11] netem: fix clang warnings Stephen Hemminger
` (9 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-08 20:46 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
From: Stephen Hemminger <stephen@networkplumber.org>
One more format attribute needed to resolve clang warnings.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
include/utils.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/utils.h b/include/utils.h
index b6c468e9cc86..d644202cc529 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -261,7 +261,9 @@ int print_timestamp(FILE *fp);
void print_nlmsg_timestamp(FILE *fp, const struct nlmsghdr *n);
unsigned int print_name_and_link(const char *fmt,
- const char *name, struct rtattr *tb[]);
+ const char *name, struct rtattr *tb[])
+ __attribute__((format(printf, 1, 0)));
+
#define BIT(nr) (UINT64_C(1) << (nr))
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH iproute2-next 03/11] netem: fix clang warnings
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 01/11] tc: add format attribute to tc_print_rate Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 02/11] utils: add format attribute Stephen Hemminger
@ 2022-01-08 20:46 ` Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 04/11] m_vlan: fix formatting of push ethernet src mac Stephen Hemminger
` (8 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-08 20:46 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
From: Stephen Hemminger <stephen@networkplumber.org>
Netem is using empty format string to not print values.
Clang complains about this hack so don't do it.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/q_netem.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/tc/q_netem.c b/tc/q_netem.c
index 2e5a46ab7b25..c483386894ea 100644
--- a/tc/q_netem.c
+++ b/tc/q_netem.c
@@ -59,10 +59,12 @@ static void explain1(const char *arg)
#define MAX_DIST (16*1024)
/* Print values only if they are non-zero */
-static void __print_int_opt(const char *label_json, const char *label_fp,
- int val)
+static void __attribute__((format(printf, 2, 0)))
+__print_int_opt(const char *label_json, const char *label_fp, int val)
{
- print_int(PRINT_ANY, label_json, val ? label_fp : "", val);
+ print_int(PRINT_JSON, label_json, NULL, val);
+ if (val != 0)
+ print_int(PRINT_FP, NULL, label_fp, val);
}
#define PRINT_INT_OPT(label, val) \
__print_int_opt(label, " " label " %d", (val))
@@ -70,8 +72,8 @@ static void __print_int_opt(const char *label_json, const char *label_fp,
/* Time print prints normally with varying units, but for JSON prints
* in seconds (1ms vs 0.001).
*/
-static void __print_time64(const char *label_json, const char *label_fp,
- __u64 val)
+static void __attribute__((format(printf, 2, 0)))
+__print_time64(const char *label_json, const char *label_fp, __u64 val)
{
SPRINT_BUF(b1);
@@ -85,8 +87,8 @@ static void __print_time64(const char *label_json, const char *label_fp,
/* Percent print prints normally in percentage points, but for JSON prints
* an absolute value (1% vs 0.01).
*/
-static void __print_percent(const char *label_json, const char *label_fp,
- __u32 per)
+static void __attribute__((format(printf, 2, 0)))
+__print_percent(const char *label_json, const char *label_fp, __u32 per)
{
print_float(PRINT_FP, NULL, label_fp, (100. * per) / UINT32_MAX);
print_float(PRINT_JSON, label_json, NULL, (1. * per) / UINT32_MAX);
@@ -802,9 +804,10 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
rate64 = rate64 ? : rate->rate;
tc_print_rate(PRINT_ANY, "rate", " rate %s", rate64);
PRINT_INT_OPT("packetoverhead", rate->packet_overhead);
- print_uint(PRINT_ANY, "cellsize",
- rate->cell_size ? " cellsize %u" : "",
- rate->cell_size);
+
+ print_uint(PRINT_JSON, "cellsize", NULL, rate->cell_size);
+ if (rate->cell_size)
+ print_uint(PRINT_FP, NULL, " cellsize %u", rate->cell_size);
PRINT_INT_OPT("celloverhead", rate->cell_overhead);
close_json_object();
}
@@ -824,9 +827,13 @@ static int netem_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
close_json_object();
}
- print_bool(PRINT_ANY, "ecn", ecn ? " ecn " : "", ecn);
- print_luint(PRINT_ANY, "gap", qopt.gap ? " gap %lu" : "",
- (unsigned long)qopt.gap);
+ print_bool(PRINT_JSON, "ecn", NULL, ecn);
+ if (ecn)
+ print_bool(PRINT_FP, NULL, " ecn ", ecn);
+
+ print_luint(PRINT_JSON, "gap", NULL, qopt.gap);
+ if (qopt.gap)
+ print_luint(PRINT_FP, NULL, " gap %lu", qopt.gap);
return 0;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH iproute2-next 04/11] m_vlan: fix formatting of push ethernet src mac
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
` (2 preceding siblings ...)
2022-01-08 20:46 ` [PATCH iproute2-next 03/11] netem: fix clang warnings Stephen Hemminger
@ 2022-01-08 20:46 ` Stephen Hemminger
2022-01-08 21:29 ` Guillaume Nault
2022-01-08 20:46 ` [PATCH iproute2-next 05/11] flower: fix clang warnings Stephen Hemminger
` (7 subsequent siblings)
11 siblings, 1 reply; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-08 20:46 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, gnault, Stephen Hemminger
This was reported as a clang warning:
CC m_vlan.o
m_vlan.c:282:32: warning: converting the enum constant to a boolean [-Wint-in-bool-context]
if (tb[TCA_VLAN_PUSH_ETH_SRC &&
^
But it is really a bug in the code for displaying the pushed
source mac.
Fixes: d61167dd88b4 ("m_vlan: add pop_eth and push_eth actions")
Cc: gnault@redhat.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/m_vlan.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tc/m_vlan.c b/tc/m_vlan.c
index 221083dfc0da..1b2b1d51ed2d 100644
--- a/tc/m_vlan.c
+++ b/tc/m_vlan.c
@@ -279,8 +279,8 @@ static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg)
ETH_ALEN, 0, b1, sizeof(b1));
print_string(PRINT_ANY, "dst_mac", " dst_mac %s", b1);
}
- if (tb[TCA_VLAN_PUSH_ETH_SRC &&
- RTA_PAYLOAD(tb[TCA_VLAN_PUSH_ETH_SRC]) == ETH_ALEN]) {
+ if (tb[TCA_VLAN_PUSH_ETH_SRC] &&
+ RTA_PAYLOAD(tb[TCA_VLAN_PUSH_ETH_SRC]) == ETH_ALEN) {
ll_addr_n2a(RTA_DATA(tb[TCA_VLAN_PUSH_ETH_SRC]),
ETH_ALEN, 0, b1, sizeof(b1));
print_string(PRINT_ANY, "src_mac", " src_mac %s", b1);
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH iproute2-next 05/11] flower: fix clang warnings
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
` (3 preceding siblings ...)
2022-01-08 20:46 ` [PATCH iproute2-next 04/11] m_vlan: fix formatting of push ethernet src mac Stephen Hemminger
@ 2022-01-08 20:46 ` Stephen Hemminger
2022-01-11 16:00 ` David Ahern
2022-01-08 20:46 ` [PATCH iproute2-next 06/11] nexthop: fix clang warning about timer check Stephen Hemminger
` (6 subsequent siblings)
11 siblings, 1 reply; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-08 20:46 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
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 | 62 ++++++++++++++++++++++++---------------------------
1 file changed, 29 insertions(+), 33 deletions(-)
diff --git a/tc/f_flower.c b/tc/f_flower.c
index 7f78195fd303..d6ff94ddbefb 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -1925,10 +1925,17 @@ 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_string(const char *name, const char *value)
+{
+ print_nl();
+ print_string(PRINT_JSON, name, NULL, value);
+ print_string(PRINT_FP, NULL, " %s", name);
+ print_string(PRINT_FP, NULL, " %s", value);
+}
+
+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;
@@ -1949,9 +1956,7 @@ static void flower_print_eth_addr(char *name, struct rtattr *addr_attr,
sprintf(out + done, "/%d", bits);
}
- print_nl();
- sprintf(namefrm, " %s %%s", name);
- print_string(PRINT_ANY, name, namefrm, out);
+ flower_print_string(name, out);
}
static void flower_print_eth_type(__be16 *p_eth_type,
@@ -2064,7 +2069,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;
@@ -2095,10 +2099,9 @@ static void flower_print_ip_addr(char *name, __be16 eth_type,
else if (bits < len * 8)
sprintf(out + done, "/%d", bits);
- print_nl();
- sprintf(namefrm, " %s %%s", name);
- print_string(PRINT_ANY, name, namefrm, out);
+ flower_print_string(name, out);
}
+
static void flower_print_ip4_addr(char *name, struct rtattr *addr_attr,
struct rtattr *mask_attr)
{
@@ -2124,22 +2127,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);
+
+ flower_print_string(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;
@@ -2150,9 +2150,7 @@ static void flower_print_tcp_flags(const char *name, struct rtattr *flags_attr,
if (mask_attr)
sprintf(out + done, "/%x", rta_getattr_be16(mask_attr));
- print_nl();
- sprintf(namefrm, " %s %%s", name);
- print_string(PRINT_ANY, name, namefrm, out);
+ flower_print_string(name, out);
}
static void flower_print_ct_state(struct rtattr *flags_attr,
@@ -2237,16 +2235,20 @@ static void flower_print_ct_mark(struct rtattr *attr,
print_masked_u32("ct_mark", attr, mask_attr, true);
}
-static void flower_print_key_id(const char *name, struct rtattr *attr)
+static void flower_print_uint(const char *name, unsigned int val)
{
- SPRINT_BUF(namefrm);
+ print_nl();
+ print_uint(PRINT_JSON, name, NULL, val);
+ print_string(PRINT_FP, NULL, " %s", name);
+ print_uint(PRINT_FP, NULL, " %%u", val);
+}
+static void flower_print_key_id(const char *name, struct rtattr *attr)
+{
if (!attr)
return;
- print_nl();
- sprintf(namefrm, " %s %%u", name);
- print_uint(PRINT_ANY, name, namefrm, rta_getattr_be32(attr));
+ flower_print_uint(name, rta_getattr_be32(attr));
}
static void flower_print_geneve_opts(const char *name, struct rtattr *attr,
@@ -2342,8 +2344,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 +2434,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;
@@ -2451,9 +2453,7 @@ static void flower_print_masked_u8(const char *name, struct rtattr *attr,
if (mask != UINT8_MAX)
sprintf(out + done, "/%d", mask);
- print_nl();
- sprintf(namefrm, " %s %%s", name);
- print_string(PRINT_ANY, name, namefrm, out);
+ flower_print_string(name, out);
}
static void flower_print_u8(const char *name, struct rtattr *attr)
@@ -2463,14 +2463,10 @@ 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));
+ flower_print_uint(name, rta_getattr_u32(attr));
}
static void flower_print_mpls_opt_lse(struct rtattr *lse)
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH iproute2-next 06/11] nexthop: fix clang warning about timer check
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
` (4 preceding siblings ...)
2022-01-08 20:46 ` [PATCH iproute2-next 05/11] flower: fix clang warnings Stephen Hemminger
@ 2022-01-08 20:46 ` Stephen Hemminger
2022-01-11 13:31 ` Ido Schimmel
2022-01-11 16:01 ` David Ahern
2022-01-08 20:46 ` [PATCH iproute2-next 07/11] tc_util: fix clang warning in print_masked_type Stephen Hemminger
` (5 subsequent siblings)
11 siblings, 2 replies; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-08 20:46 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, idosch
Clang correctly flags that ipnexthop is comparing timer
with a value that it can never have.
On 64 bit platform ~0UL / 100 = 184467440737095516
and timer is u32 so max is 4294967295.
Fixes: 91676718228b ("nexthop: Add support for resilient nexthop groups")
Cc: idosch@nvidia.com
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
ip/ipnexthop.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/ip/ipnexthop.c b/ip/ipnexthop.c
index 83a5540e771c..2c65df294587 100644
--- a/ip/ipnexthop.c
+++ b/ip/ipnexthop.c
@@ -31,6 +31,8 @@ enum {
IPNH_FLUSH,
};
+#define TIMER_MAX (~(__u32)0 / 100)
+
#define RTM_NHA(h) ((struct rtattr *)(((char *)(h)) + \
NLMSG_ALIGN(sizeof(struct nhmsg))))
@@ -839,8 +841,8 @@ static void parse_nh_group_type_res(struct nlmsghdr *n, int maxlen, int *argcp,
__u32 idle_timer;
NEXT_ARG();
- if (get_unsigned(&idle_timer, *argv, 0) ||
- idle_timer >= ~0UL / 100)
+ if (get_u32(&idle_timer, *argv, 0) ||
+ idle_timer >= TIMER_MAX)
invarg("invalid idle timer value", *argv);
addattr32(n, maxlen, NHA_RES_GROUP_IDLE_TIMER,
@@ -849,8 +851,8 @@ static void parse_nh_group_type_res(struct nlmsghdr *n, int maxlen, int *argcp,
__u32 unbalanced_timer;
NEXT_ARG();
- if (get_unsigned(&unbalanced_timer, *argv, 0) ||
- unbalanced_timer >= ~0UL / 100)
+ if (get_u32(&unbalanced_timer, *argv, 0) ||
+ unbalanced_timer >= TIMER_MAX)
invarg("invalid unbalanced timer value", *argv);
addattr32(n, maxlen, NHA_RES_GROUP_UNBALANCED_TIMER,
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH iproute2-next 07/11] tc_util: fix clang warning in print_masked_type
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
` (5 preceding siblings ...)
2022-01-08 20:46 ` [PATCH iproute2-next 06/11] nexthop: fix clang warning about timer check Stephen Hemminger
@ 2022-01-08 20:46 ` Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 08/11] ipl2tp: fix clang warning Stephen Hemminger
` (4 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-08 20:46 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, elibr, Stephen Hemminger
Clang complains about passing a non-format string but the code here
was doing extra work the JSON case. It was also broken if using oneline mode.
Fixes: 04b215015ba8 ("tc_util: introduce a function to print JSON/non-JSON masked numbers")
Cc: elibr@mellanox.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tc/tc_util.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 6d5eb754831a..c95b6fd6e49d 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -783,7 +783,6 @@ static void print_masked_type(__u32 type_max,
const char *name, struct rtattr *attr,
struct rtattr *mask_attr, bool newline)
{
- SPRINT_BUF(namefrm);
__u32 value, mask;
SPRINT_BUF(out);
size_t done;
@@ -795,26 +794,21 @@ static void print_masked_type(__u32 type_max,
mask = mask_attr ? rta_getattr_type(mask_attr) : type_max;
if (is_json_context()) {
- sprintf(namefrm, "\n %s %%u", name);
- print_hu(PRINT_ANY, name, namefrm,
- rta_getattr_type(attr));
+ print_hu(PRINT_JSON, name, NULL, value);
if (mask != type_max) {
char mask_name[SPRINT_BSIZE-6];
sprintf(mask_name, "%s_mask", name);
- if (newline)
- print_string(PRINT_FP, NULL, "%s ", _SL_);
- sprintf(namefrm, " %s %%u", mask_name);
- print_hu(PRINT_ANY, mask_name, namefrm, mask);
+ print_hu(PRINT_JSON, mask_name, NULL, mask);
}
} else {
done = sprintf(out, "%u", value);
if (mask != type_max)
sprintf(out + done, "/0x%x", mask);
- if (newline)
- print_string(PRINT_FP, NULL, "%s ", _SL_);
- sprintf(namefrm, " %s %%s", name);
- print_string(PRINT_ANY, name, namefrm, out);
+
+ print_nl();
+ print_string(PRINT_FP, NULL, " %s", name);
+ print_string(PRINT_FP, NULL, " %s", out);
}
}
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH iproute2-next 08/11] ipl2tp: fix clang warning
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
` (6 preceding siblings ...)
2022-01-08 20:46 ` [PATCH iproute2-next 07/11] tc_util: fix clang warning in print_masked_type Stephen Hemminger
@ 2022-01-08 20:46 ` Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 09/11] can: " Stephen Hemminger
` (3 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-08 20:46 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, Stephen Hemminger
Clang complains about passing non-format string.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/ipl2tp.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ip/ipl2tp.c b/ip/ipl2tp.c
index 77bc3249c7ec..569723581ec2 100644
--- a/ip/ipl2tp.c
+++ b/ip/ipl2tp.c
@@ -191,8 +191,9 @@ static int delete_session(struct l2tp_parm *p)
return 0;
}
-static void print_cookie(const char *name, const char *fmt,
- const uint8_t *cookie, int len)
+static void __attribute__((format(printf, 2, 0)))
+print_cookie(const char *name, const char *fmt,
+ const uint8_t *cookie, int len)
{
char abuf[32];
size_t n;
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH iproute2-next 09/11] can: fix clang warning
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
` (7 preceding siblings ...)
2022-01-08 20:46 ` [PATCH iproute2-next 08/11] ipl2tp: fix clang warning Stephen Hemminger
@ 2022-01-08 20:46 ` Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 10/11] tipc: fix clang warning about empty format string Stephen Hemminger
` (2 subsequent siblings)
11 siblings, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-08 20:46 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, Stephen Hemminger
Fix warning about passing non-format string.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/iplink_can.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/ip/iplink_can.c b/ip/iplink_can.c
index f4b375280cd7..67c913808083 100644
--- a/ip/iplink_can.c
+++ b/ip/iplink_can.c
@@ -330,8 +330,9 @@ static void can_print_nl_indent(void)
print_string(PRINT_FP, NULL, "%s", "\t ");
}
-static void can_print_timing_min_max(const char *json_attr, const char *fp_attr,
- int min, int max)
+static void __attribute__((format(printf, 2, 0)))
+can_print_timing_min_max(const char *json_attr, const char *fp_attr,
+ int min, int max)
{
print_null(PRINT_FP, NULL, fp_attr, NULL);
open_json_object(json_attr);
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH iproute2-next 10/11] tipc: fix clang warning about empty format string
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
` (8 preceding siblings ...)
2022-01-08 20:46 ` [PATCH iproute2-next 09/11] can: " Stephen Hemminger
@ 2022-01-08 20:46 ` Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 11/11] tunnel: fix clang warning Stephen Hemminger
2022-01-10 17:20 ` [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
11 siblings, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-08 20:46 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, Stephen Hemminger
When calling json_print with json only use a NULL instead of
empty string.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
tipc/link.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tipc/link.c b/tipc/link.c
index 9994ada2a367..53f49c8937db 100644
--- a/tipc/link.c
+++ b/tipc/link.c
@@ -332,7 +332,7 @@ static int _show_link_stat(const char *name, struct nlattr *attrs[],
open_json_object(NULL);
print_string(PRINT_ANY, "link", "Link <%s>\n", name);
- print_string(PRINT_JSON, "state", "", NULL);
+ print_string(PRINT_JSON, "state", NULL, NULL);
open_json_array(PRINT_JSON, NULL);
if (attrs[TIPC_NLA_LINK_ACTIVE])
print_string(PRINT_ANY, NULL, " %s", "ACTIVE");
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH iproute2-next 11/11] tunnel: fix clang warning
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
` (9 preceding siblings ...)
2022-01-08 20:46 ` [PATCH iproute2-next 10/11] tipc: fix clang warning about empty format string Stephen Hemminger
@ 2022-01-08 20:46 ` Stephen Hemminger
2022-01-10 17:20 ` [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
11 siblings, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-08 20:46 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, Stephen Hemminger
To fix clang warning about passing non-format string split the
print into two calls.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
ip/tunnel.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/ip/tunnel.c b/ip/tunnel.c
index 88585cf3177b..9d1a745d9d2d 100644
--- a/ip/tunnel.c
+++ b/ip/tunnel.c
@@ -301,10 +301,8 @@ void tnl_print_endpoint(const char *name, const struct rtattr *rta, int family)
if (is_json_context()) {
print_string(PRINT_JSON, name, NULL, value);
} else {
- SPRINT_BUF(b1);
-
- snprintf(b1, sizeof(b1), "%s %%s ", name);
- print_string(PRINT_FP, NULL, b1, value);
+ print_string(PRINT_FP, NULL, "%s ", name);
+ print_string(PRINT_FP, NULL, "%s ",value);
}
}
--
2.30.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH iproute2-next 04/11] m_vlan: fix formatting of push ethernet src mac
2022-01-08 20:46 ` [PATCH iproute2-next 04/11] m_vlan: fix formatting of push ethernet src mac Stephen Hemminger
@ 2022-01-08 21:29 ` Guillaume Nault
0 siblings, 0 replies; 17+ messages in thread
From: Guillaume Nault @ 2022-01-08 21:29 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Stephen Hemminger
On Sat, Jan 08, 2022 at 12:46:43PM -0800, Stephen Hemminger wrote:
> This was reported as a clang warning:
> CC m_vlan.o
> m_vlan.c:282:32: warning: converting the enum constant to a boolean [-Wint-in-bool-context]
> if (tb[TCA_VLAN_PUSH_ETH_SRC &&
> ^
>
> But it is really a bug in the code for displaying the pushed
> source mac.
>
> Fixes: d61167dd88b4 ("m_vlan: add pop_eth and push_eth actions")
> Cc: gnault@redhat.com
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> tc/m_vlan.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tc/m_vlan.c b/tc/m_vlan.c
> index 221083dfc0da..1b2b1d51ed2d 100644
> --- a/tc/m_vlan.c
> +++ b/tc/m_vlan.c
> @@ -279,8 +279,8 @@ static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg)
> ETH_ALEN, 0, b1, sizeof(b1));
> print_string(PRINT_ANY, "dst_mac", " dst_mac %s", b1);
> }
> - if (tb[TCA_VLAN_PUSH_ETH_SRC &&
> - RTA_PAYLOAD(tb[TCA_VLAN_PUSH_ETH_SRC]) == ETH_ALEN]) {
> + if (tb[TCA_VLAN_PUSH_ETH_SRC] &&
> + RTA_PAYLOAD(tb[TCA_VLAN_PUSH_ETH_SRC]) == ETH_ALEN) {
> ll_addr_n2a(RTA_DATA(tb[TCA_VLAN_PUSH_ETH_SRC]),
> ETH_ALEN, 0, b1, sizeof(b1));
> print_string(PRINT_ANY, "src_mac", " src_mac %s", b1);
This is already fixed in iproute2 with commit 0e949725908b ("tc/m_vlan:
fix print_vlan() conditional on TCA_VLAN_ACT_PUSH_ETH").
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH iproute2-next 00/11] Clang warning fixes
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
` (10 preceding siblings ...)
2022-01-08 20:46 ` [PATCH iproute2-next 11/11] tunnel: fix clang warning Stephen Hemminger
@ 2022-01-10 17:20 ` Stephen Hemminger
11 siblings, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2022-01-10 17:20 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger
On Sat, 8 Jan 2022 12:46:39 -0800
Stephen Hemminger <stephen@networkplumber.org> wrote:
> Building iproute2-next generates a lot of warnings and
> finds a few bugs. This patchset resolves many of these
> warnings but some areas (BPF, RDMA, DCB) need more work.
>
> Stephen Hemminger (11):
> tc: add format attribute to tc_print_rate
> utils: add format attribute
> netem: fix clang warnings
> m_vlan: fix formatting of push ethernet src mac
> flower: fix clang warnings
> nexthop: fix clang warning about timer check
> tc_util: fix clang warning in print_masked_type
> ipl2tp: fix clang warning
> can: fix clang warning
> tipc: fix clang warning about empty format string
> tunnel: fix clang warning
>
> include/utils.h | 4 +++-
> ip/ipl2tp.c | 5 ++--
> ip/iplink_can.c | 5 ++--
> ip/ipnexthop.c | 10 ++++----
> ip/tunnel.c | 6 ++---
> tc/f_flower.c | 62 +++++++++++++++++++++++--------------------------
> tc/m_vlan.c | 4 ++--
> tc/q_netem.c | 33 +++++++++++++++-----------
> tc/tc_util.c | 21 +++++++----------
> tipc/link.c | 2 +-
> 10 files changed, 77 insertions(+), 75 deletions(-)
>
Will resend this after 5.16 merge. Some of these are already fixed
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH iproute2-next 06/11] nexthop: fix clang warning about timer check
2022-01-08 20:46 ` [PATCH iproute2-next 06/11] nexthop: fix clang warning about timer check Stephen Hemminger
@ 2022-01-11 13:31 ` Ido Schimmel
2022-01-11 16:01 ` David Ahern
1 sibling, 0 replies; 17+ messages in thread
From: Ido Schimmel @ 2022-01-11 13:31 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Stephen Hemminger, idosch
On Sat, Jan 08, 2022 at 12:46:45PM -0800, Stephen Hemminger wrote:
> diff --git a/ip/ipnexthop.c b/ip/ipnexthop.c
> index 83a5540e771c..2c65df294587 100644
> --- a/ip/ipnexthop.c
> +++ b/ip/ipnexthop.c
> @@ -31,6 +31,8 @@ enum {
> IPNH_FLUSH,
> };
>
> +#define TIMER_MAX (~(__u32)0 / 100)
> +
> #define RTM_NHA(h) ((struct rtattr *)(((char *)(h)) + \
> NLMSG_ALIGN(sizeof(struct nhmsg))))
>
> @@ -839,8 +841,8 @@ static void parse_nh_group_type_res(struct nlmsghdr *n, int maxlen, int *argcp,
> __u32 idle_timer;
>
> NEXT_ARG();
> - if (get_unsigned(&idle_timer, *argv, 0) ||
> - idle_timer >= ~0UL / 100)
> + if (get_u32(&idle_timer, *argv, 0) ||
> + idle_timer >= TIMER_MAX)
> invarg("invalid idle timer value", *argv);
>
> addattr32(n, maxlen, NHA_RES_GROUP_IDLE_TIMER,
> @@ -849,8 +851,8 @@ static void parse_nh_group_type_res(struct nlmsghdr *n, int maxlen, int *argcp,
> __u32 unbalanced_timer;
>
> NEXT_ARG();
> - if (get_unsigned(&unbalanced_timer, *argv, 0) ||
> - unbalanced_timer >= ~0UL / 100)
> + if (get_u32(&unbalanced_timer, *argv, 0) ||
> + unbalanced_timer >= TIMER_MAX)
> invarg("invalid unbalanced timer value", *argv);
I believe these were already addressed by:
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=5f8bb902e14f91161f9ed214d5fc1d813af8ed88
>
> addattr32(n, maxlen, NHA_RES_GROUP_UNBALANCED_TIMER,
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH iproute2-next 05/11] flower: fix clang warnings
2022-01-08 20:46 ` [PATCH iproute2-next 05/11] flower: fix clang warnings Stephen Hemminger
@ 2022-01-11 16:00 ` David Ahern
0 siblings, 0 replies; 17+ messages in thread
From: David Ahern @ 2022-01-11 16:00 UTC (permalink / raw)
To: Stephen Hemminger, netdev; +Cc: Stephen Hemminger
On 1/8/22 1:46 PM, Stephen Hemminger wrote:
> @@ -1925,10 +1925,17 @@ 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_string(const char *name, const char *value)
> +{
> + print_nl();
> + print_string(PRINT_JSON, name, NULL, value);
> + print_string(PRINT_FP, NULL, " %s", name);
> + print_string(PRINT_FP, NULL, " %s", value);
> +}
> +
The last 3 lines could be a generic print_string_name_value function
under lib.
> @@ -2237,16 +2235,20 @@ static void flower_print_ct_mark(struct rtattr *attr,
> print_masked_u32("ct_mark", attr, mask_attr, true);
> }
>
> -static void flower_print_key_id(const char *name, struct rtattr *attr)
> +static void flower_print_uint(const char *name, unsigned int val)
> {
> - SPRINT_BUF(namefrm);
> + print_nl();
> + print_uint(PRINT_JSON, name, NULL, val);
> + print_string(PRINT_FP, NULL, " %s", name);
> + print_uint(PRINT_FP, NULL, " %%u", val);
s/%%u/%u/ ?
Same here the last 3 lines could be a lib function.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH iproute2-next 06/11] nexthop: fix clang warning about timer check
2022-01-08 20:46 ` [PATCH iproute2-next 06/11] nexthop: fix clang warning about timer check Stephen Hemminger
2022-01-11 13:31 ` Ido Schimmel
@ 2022-01-11 16:01 ` David Ahern
1 sibling, 0 replies; 17+ messages in thread
From: David Ahern @ 2022-01-11 16:01 UTC (permalink / raw)
To: Stephen Hemminger, netdev; +Cc: Stephen Hemminger, idosch
On 1/8/22 1:46 PM, Stephen Hemminger wrote:
> diff --git a/ip/ipnexthop.c b/ip/ipnexthop.c
> index 83a5540e771c..2c65df294587 100644
> --- a/ip/ipnexthop.c
> +++ b/ip/ipnexthop.c
> @@ -31,6 +31,8 @@ enum {
> IPNH_FLUSH,
> };
>
> +#define TIMER_MAX (~(__u32)0 / 100)
UINT_MAX instead of "~(__u32)0)"
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2022-01-11 16:01 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-08 20:46 [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 01/11] tc: add format attribute to tc_print_rate Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 02/11] utils: add format attribute Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 03/11] netem: fix clang warnings Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 04/11] m_vlan: fix formatting of push ethernet src mac Stephen Hemminger
2022-01-08 21:29 ` Guillaume Nault
2022-01-08 20:46 ` [PATCH iproute2-next 05/11] flower: fix clang warnings Stephen Hemminger
2022-01-11 16:00 ` David Ahern
2022-01-08 20:46 ` [PATCH iproute2-next 06/11] nexthop: fix clang warning about timer check Stephen Hemminger
2022-01-11 13:31 ` Ido Schimmel
2022-01-11 16:01 ` David Ahern
2022-01-08 20:46 ` [PATCH iproute2-next 07/11] tc_util: fix clang warning in print_masked_type Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 08/11] ipl2tp: fix clang warning Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 09/11] can: " Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 10/11] tipc: fix clang warning about empty format string Stephen Hemminger
2022-01-08 20:46 ` [PATCH iproute2-next 11/11] tunnel: fix clang warning Stephen Hemminger
2022-01-10 17:20 ` [PATCH iproute2-next 00/11] Clang warning fixes Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).