The current form of EV_SET(2) declares a `kevp' variable. This can
cause to subtle bugs hard to discover if one uses a variable of the
same to retrieve events.
Diff below prefixes the locally declared variable by an underscore,
like it it done in FD_ZERO(), which should be good enough to prevent
surprises.
Is it the right way to correct such issue? How many underscores are
enough? Can the standards gurus tell me?
Index: sys/event.h
===================================================================
RCS file: /cvs/src/sys/sys/event.h,v
retrieving revision 1.33
diff -u -p -r1.33 event.h
--- sys/event.h 20 Feb 2020 16:56:52 -0000 1.33
+++ sys/event.h 1 Apr 2020 08:16:05 -0000
@@ -42,14 +42,14 @@
#define EVFILT_SYSCOUNT 8
-#define EV_SET(kevp_, a, b, c, d, e, f) do { \
- struct kevent *kevp = (kevp_); \
- (kevp)->ident = (a); \
- (kevp)->filter = (b); \
- (kevp)->flags = (c); \
- (kevp)->fflags = (d); \
- (kevp)->data = (e); \
- (kevp)->udata = (f); \
+#define EV_SET(kevp, a, b, c, d, e, f) do { \
+ struct kevent *_kevp = (kevp); \
+ (_kevp)->ident = (a); \
+ (_kevp)->filter = (b); \
+ (_kevp)->flags = (c); \
+ (_kevp)->fflags = (d); \
+ (_kevp)->data = (e); \
+ (_kevp)->udata = (f); \
} while(0)
struct kevent {