svn commit: r336200 - stable/10/sys/sys
David Bright
dab at FreeBSD.org
Wed Jul 11 14:56:39 UTC 2018
Author: dab
Date: Wed Jul 11 14:56:38 2018
New Revision: 336200
URL: https://svnweb.freebsd.org/changeset/base/336200
Log:
MFC r335765, r335776, r336186:
Remove potential identifier conflict in the EV_SET macro.
PR43905 pointed out a problem with the EV_SET macro if the passed
struct kevent pointer were specified with an expression with side
effects (e.g., "kevp++"). This was fixed in rS110241, but by using a
local block that defined an internal variable (named "kevp") to get
the pointer value once. This worked, but could cause issues if an
existing variable named "kevp" is in scope. To avoid that issue,
jilles@ pointed out that "C99 compound literals and designated
initializers allow doing this cleanly using a macro". This change
incorporates that suggestion, essentially verbatim from jilles@
comment on PR43905, except retaining the old definition for pre-C99 or
non-STDC (e.g., C++) compilers.
PR: 43905
Submitted by: Jilles Tjoelker (jilles@)
Reported by: Lamont Granquist <lamont at scriptkiddie.org>
Sponsored by: Dell EMC
Modified:
stable/10/sys/sys/event.h
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/sys/event.h
==============================================================================
--- stable/10/sys/sys/event.h Wed Jul 11 14:54:56 2018 (r336199)
+++ stable/10/sys/sys/event.h Wed Jul 11 14:56:38 2018 (r336200)
@@ -44,6 +44,21 @@
#define EVFILT_USER (-11) /* User events */
#define EVFILT_SYSCOUNT 11
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define EV_SET(kevp_, a, b, c, d, e, f) do { \
+ *(kevp_) = (struct kevent){ \
+ .ident = (a), \
+ .filter = (b), \
+ .flags = (c), \
+ .fflags = (d), \
+ .data = (e), \
+ .udata = (f), \
+ }; \
+} while(0)
+#else /* Pre-C99 or not STDC (e.g., C++) */
+/* The definition of the local variable kevp could possibly conflict
+ * with a user-defined value passed in parameters a-f.
+ */
#define EV_SET(kevp_, a, b, c, d, e, f) do { \
struct kevent *kevp = (kevp_); \
(kevp)->ident = (a); \
@@ -53,6 +68,7 @@
(kevp)->data = (e); \
(kevp)->udata = (f); \
} while(0)
+#endif
struct kevent {
uintptr_t ident; /* identifier for this event */
More information about the svn-src-stable-10
mailing list