Author: hselasky
Date: Thu Nov 30 11:35:22 2017
New Revision: 326392
URL: https://svnweb.freebsd.org/changeset/base/326392

Log:
  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
  MFC after:    3 days
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/net/if_vlan_var.h

Modified: head/sys/net/if_vlan_var.h
==============================================================================
--- head/sys/net/if_vlan_var.h  Thu Nov 30 08:28:17 2017        (r326391)
+++ head/sys/net/if_vlan_var.h  Thu Nov 30 11:35:22 2017        (r326392)
@@ -143,16 +143,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, _vid)                                    \
-       (_ifp)->if_type == IFT_L2VLAN ? (*vlan_tag_p)((_ifp), (_vid)) : EINVAL
+       ((_ifp)->if_type == IFT_L2VLAN ? (*vlan_tag_p)((_ifp), (_vid)) : 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, _vid)                                  \
-       (_ifp)->if_vlantrunk != NULL ? (*vlan_devat_p)((_ifp), (_vid)) : NULL
+       ((_ifp)->if_vlantrunk != NULL ? (*vlan_devat_p)((_ifp), (_vid)) : NULL)
 
 extern void (*vlan_trunk_cap_p)(struct ifnet *);
 extern struct ifnet *(*vlan_trunkdev_p)(struct ifnet *);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to