On 02/04/20(Thu) 13:36, Philip Guenther wrote: > On Tue, Mar 31, 2020 at 11:24 PM Martin Pieuchot <m...@openbsd.org> wrote: > > > 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? > > > > tl;dr: this should use a variable that starts with either two underbars > (__kevp) or an underbar and a capital (_Kevp). The same is true of > FD_ZERO(). > [...]
Thanks, here it is, ok? 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 3 Apr 2020 07:47:17 -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 { Index: sys/select.h =================================================================== RCS file: /cvs/src/sys/sys/select.h,v retrieving revision 1.17 diff -u -p -r1.17 select.h --- sys/select.h 12 Sep 2016 19:41:20 -0000 1.17 +++ sys/select.h 3 Apr 2020 07:48:31 -0000 @@ -100,11 +100,11 @@ __fd_isset(int fd, const fd_set *p) #define FD_COPY(f, t) (void)(*(t) = *(f)) #endif #define FD_ZERO(p) do { \ - fd_set *_p = (p); \ - __size_t _n = __howmany(FD_SETSIZE, __NFDBITS); \ + fd_set *__p = (p); \ + __size_t __n = __howmany(FD_SETSIZE, __NFDBITS); \ \ - while (_n > 0) \ - _p->fds_bits[--_n] = 0; \ + while (__n > 0) \ + __p->fds_bits[--__n] = 0; \ } while (0) #if __BSD_VISIBLE