From 2c14bf327957247bb9e7b1abc96c56a4ad239b9b Mon Sep 17 00:00:00 2001 From: hselasky Date: Mon, 4 Dec 2017 09:36:47 +0000 Subject: [PATCH] MFC r326392: Properly define the VLAN_XXX() function macros to avoid miscompilation when used inside "if" statements comparing with another value. Detailed explanation: "if (a ? b : c != 0)" is not the same like "if ((a ? b : c) != 0)" which is the expected behaviour of a function macro. Affects: toecore, linuxkpi and ibcore. Reviewed by: kib Sponsored by: Mellanox Technologies git-svn-id: svn://svn.freebsd.org/base/stable/9@326513 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/net/if_vlan_var.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/net/if_vlan_var.h b/sys/net/if_vlan_var.h index fd3fc4f3c..286d583f5 100644 --- a/sys/net/if_vlan_var.h +++ b/sys/net/if_vlan_var.h @@ -132,16 +132,16 @@ struct vlanreq { } while (0) #define VLAN_TRUNKDEV(_ifp) \ - (_ifp)->if_type == IFT_L2VLAN ? (*vlan_trunkdev_p)((_ifp)) : NULL + ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_trunkdev_p)((_ifp)) : NULL) #define VLAN_TAG(_ifp, _tag) \ - (_ifp)->if_type == IFT_L2VLAN ? (*vlan_tag_p)((_ifp), (_tag)) : EINVAL + ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_tag_p)((_ifp), (_tag)) : EINVAL) #define VLAN_COOKIE(_ifp) \ - (_ifp)->if_type == IFT_L2VLAN ? (*vlan_cookie_p)((_ifp)) : NULL + ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_cookie_p)((_ifp)) : NULL) #define VLAN_SETCOOKIE(_ifp, _cookie) \ - (_ifp)->if_type == IFT_L2VLAN ? \ - (*vlan_setcookie_p)((_ifp), (_cookie)) : EINVAL + ((_ifp)->if_type == IFT_L2VLAN ? \ + (*vlan_setcookie_p)((_ifp), (_cookie)) : EINVAL) #define VLAN_DEVAT(_ifp, _tag) \ - (_ifp)->if_vlantrunk != NULL ? (*vlan_devat_p)((_ifp), (_tag)) : NULL + ((_ifp)->if_vlantrunk != NULL ? (*vlan_devat_p)((_ifp), (_tag)) : NULL) extern void (*vlan_trunk_cap_p)(struct ifnet *); extern struct ifnet *(*vlan_trunkdev_p)(struct ifnet *); -- 2.45.0