diff mbox series

[iproute2-next,04/11] m_vlan: fix formatting of push ethernet src mac

Message ID 20220108204650.36185-5-sthemmin@microsoft.com (mailing list archive)
State Changes Requested
Delegated to: David Ahern
Headers show
Series Clang warning fixes | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Stephen Hemminger Jan. 8, 2022, 8:46 p.m. UTC
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(-)

Comments

Guillaume Nault Jan. 8, 2022, 9:29 p.m. UTC | #1
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").
diff mbox series

Patch

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);