Date: Thu, 30 Nov 2017 11:35:22 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326392 - head/sys/net Message-ID: <201711301135.vAUBZM7K066064@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 *);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711301135.vAUBZM7K066064>