Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Dec 2017 09:27:36 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r326512 - stable/10/sys/net
Message-ID:  <201712040927.vB49RatL081775@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon Dec  4 09:27:36 2017
New Revision: 326512
URL: https://svnweb.freebsd.org/changeset/base/326512

Log:
  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

Modified:
  stable/10/sys/net/if_vlan_var.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/net/if_vlan_var.h
==============================================================================
--- stable/10/sys/net/if_vlan_var.h	Mon Dec  4 09:26:12 2017	(r326511)
+++ stable/10/sys/net/if_vlan_var.h	Mon Dec  4 09:27:36 2017	(r326512)
@@ -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, _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 *);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712040927.vB49RatL081775>