Clang warning fixes
Subsystems (2)
cover Clang warning fixes
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(-)
Signature · 1 line
2.30.2
PATCH 1/11 tc: add format attribute to tc_print_rate
From: Stephen Hemminger <[email protected]>
This catches future errors and silences warning from Clang.
--- tc/tc_util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tc/tc_util.c +2 -1
@@ -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);
Signature · 1 line
2.30.2
PATCH 2/11 utils: add format attribute
In reply to Stephen HemmingerFrom: Stephen Hemminger <[email protected]>
One more format attribute needed to resolve clang warnings.
--- include/utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/utils.h +3 -1
@@ -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))
Signature · 1 line
2.30.2
PATCH 3/11 netem: fix clang warnings
In reply to Stephen HemmingerFrom: Stephen Hemminger <[email protected]>
Netem is using empty format string to not print values. Clang complains about this hack so don't do it.
--- tc/q_netem.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
tc/q_netem.c +20 -13
@@ -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 ; }
Signature · 1 line
2.30.2
PATCH 4/11 m_vlan: fix formatting of push ethernet src mac
In reply to Stephen HemmingerThis 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.
--- tc/m_vlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tc/m_vlan.c +2 -2
@@ -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);
Signature · 1 line
2.30.2
PATCH 5/11 flower: fix clang warnings
In reply to Stephen HemmingerClang complains about passing non-format string to print_string. Handle this by splitting json and non-json parts.
--- tc/f_flower.c | 62 ++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 33 deletions(-)
tc/f_flower.c +29 -33
@@ -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)
Signature · 1 line
2.30.2
PATCH 6/11 nexthop: fix clang warning about timer check
In reply to Stephen HemmingerClang 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.
--- ip/ipnexthop.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
ip/ipnexthop.c +6 -4
@@ -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,
Signature · 1 line
2.30.2
PATCH 7/11 tc_util: fix clang warning in print_masked_type
In reply to Stephen HemmingerClang 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.
--- tc/tc_util.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
tc/tc_util.c +6 -12
@@ -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); } }
Signature · 1 line
2.30.2
PATCH 8/11 ipl2tp: fix clang warning
In reply to Stephen HemmingerClang complains about passing non-format string.
--- ip/ipl2tp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
ip/ipl2tp.c +3 -2
@@ -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;
Signature · 1 line
2.30.2
PATCH 9/11 can: fix clang warning
In reply to Stephen HemmingerFix warning about passing non-format string.
--- ip/iplink_can.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
ip/iplink_can.c +3 -2
@@ -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);
Signature · 1 line
2.30.2
PATCH 10/11 tipc: fix clang warning about empty format string
In reply to Stephen HemmingerWhen calling json_print with json only use a NULL instead of empty string.
--- tipc/link.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tipc/link.c +1 -1
@@ -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" );
Signature · 1 line
2.30.2
PATCH 11/11 tunnel: fix clang warning
In reply to Stephen HemmingerTo fix clang warning about passing non-format string split the print into two calls.
--- ip/tunnel.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
ip/tunnel.c +2 -4
@@ -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); } }
Signature · 1 line
2.30.2
Re: [PATCH iproute2-next 04/11] m_vlan: fix formatting of push ethernet src mac
In reply to Stephen HemmingerQuoted 21 lines · 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")Signed-off-by Stephen Hemminger <[email protected]>--- tc/m_vlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tc/m_vlan.c +0
-0
tc/m_vlan.c static int print_vlan(struct action_util *au, FILE *f, struct rtattr *arg) · line 286
Quoted 10 lines
tc/m_vlan.c +2
-2@@ -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").
Quoted 17 lines · On Sat, 8 Jan 2022 12:46:39 -0800 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 totc_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 inprint_masked_type
ipl2tp: fix clang warning
can: fix clang warning
tipc: fix clang warning about empty format string
tunnel: fix clang warning
Quoted 12 lines
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
Re: [PATCH iproute2-next 06/11] nexthop: fix clang warning about timer check
In reply to Stephen HemmingerQuoted 25 lines · Stephen Hemminger
ip/ipnexthop.c +4
-2@@ -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,
ip/ipnexthop.c static void parse_nh_group_type_res(struct nlmsghdr *n, int maxlen, int *argcp, · line 856
Quoted 8 lines
ip/ipnexthop.c +2
-2@@ -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
Quoted 5 lines
ip/ipnexthop.c +0
-0addattr32(n, maxlen, NHA_RES_GROUP_UNBALANCED_TIMER,Signature · 1 line
2.30.2
Re: [PATCH iproute2-next 05/11] flower: fix clang warnings
In reply to Stephen Hemmingertc/f_flower.c static int __mask_bits(char *addr, size_t len) · line 1935
Quoted 13 lines · Stephen Hemminger
tc/f_flower.c +8
-1@@ -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.
tc/f_flower.c static void flower_print_ct_mark(struct rtattr *attr, · line 2243
Quoted 12 lines
tc/f_flower.c +5
-2@@ -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.
Re: [PATCH iproute2-next 06/11] nexthop: fix clang warning about timer check
In reply to Stephen Hemmingerip/ipnexthop.c enum { · line 34
Quoted 9 lines · Stephen Hemminger
ip/ipnexthop.c +1
-0@@ -31,6 +31,8 @@ enum { IPNH_FLUSH, }; +#define TIMER_MAX (~(__u32)0 / 100)
UINT_MAX instead of "~(__u32)0)"