Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jun 2018 13:45:24 -0500
From:      Justin Hibbits <jrh29@alumni.cwru.edu>
To:        dab@freebsd.org
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r335765 - head/sys/sys
Message-ID:  <CAHSQbTD5BtcvcMeA%2BZeAUfkdsB6F%2BY9G182rnOHwb-E%2ByGxCUw@mail.gmail.com>
In-Reply-To: <201806281701.w5SH15eP011261@repo.freebsd.org>
References:  <201806281701.w5SH15eP011261@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi David,

On Thu, Jun 28, 2018 at 12:01 PM David Bright <dab@freebsd.org> wrote:
>
> Author: dab
> Date: Thu Jun 28 17:01:04 2018
> New Revision: 335765
> URL: https://svnweb.freebsd.org/changeset/base/335765
>
> Log:
>   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@scriptkiddie.org>
>   Reviewed by:  jmg (no comments), jilles
>   MFC after:    1 week
>   Sponsored by: Dell EMC
>   Differential Revision:        https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=43905
>
> Modified:
>   head/sys/sys/event.h
>
> Modified: head/sys/sys/event.h
> ==============================================================================
> --- head/sys/sys/event.h        Thu Jun 28 15:30:51 2018        (r335764)
> +++ head/sys/sys/event.h        Thu Jun 28 17:01:04 2018        (r335765)
> @@ -49,7 +49,26 @@
>  #define EVFILT_EMPTY           (-13)   /* empty send socket buf */
>  #define EVFILT_SYSCOUNT                13
>
> +#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),                           \
> +       .ext[0] = 0,                            \
> +       .ext[1] = 0,                            \
> +       .ext[2] = 0,                            \
> +       .ext[3] = 0,                            \
> +    };                                         \
> +} 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);                    \
>         (kevp)->filter = (b);                   \
> @@ -62,6 +81,7 @@
>         (kevp)->ext[2] = 0;                     \
>         (kevp)->ext[3] = 0;                     \
>  } while(0)
> +#endif
>
>  struct kevent {
>         __uintptr_t     ident;          /* identifier for this event */
>

This breaks gcc builds, with the following errors:

18:02:13 /usr/src/bin/pwait/pwait.c: In function 'main':
18:02:13 /usr/src/bin/pwait/pwait.c:144: warning: initialized field overwritten
18:02:13 /usr/src/bin/pwait/pwait.c:144: warning: (near initialization
for '(anonymous).ext')
18:02:13 /usr/src/bin/pwait/pwait.c:144: warning: initialized field overwritten
18:02:13 /usr/src/bin/pwait/pwait.c:144: warning: (near initialization
for '(anonymous).ext')
18:02:13 /usr/src/bin/pwait/pwait.c:144: warning: initialized field overwritten
18:02:13 /usr/src/bin/pwait/pwait.c:144: warning: (near initialization
for '(anonymous).ext')
18:02:13 /usr/src/bin/pwait/pwait.c:158: warning: initialized field overwritten
18:02:13 /usr/src/bin/pwait/pwait.c:158: warning: (near initialization
for '(anonymous).ext')
18:02:13 /usr/src/bin/pwait/pwait.c:158: warning: initialized field overwritten
18:02:13 /usr/src/bin/pwait/pwait.c:158: warning: (near initialization
for '(anonymous).ext')
18:02:13 /usr/src/bin/pwait/pwait.c:158: warning: initialized field overwritten
18:02:13 /usr/src/bin/pwait/pwait.c:158: warning: (near initialization
for '(anonymous).ext')

This can be seen in the tinderbox (https://ci.freebsd.org/tinderbox)

I encountered this as a failure in building usr.sbin/camdd, which
shows the same type of error.

- Justin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAHSQbTD5BtcvcMeA%2BZeAUfkdsB6F%2BY9G182rnOHwb-E%2ByGxCUw>