From owner-svn-src-head@freebsd.org Thu Jun 28 19:40:19 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AA7641025492; Thu, 28 Jun 2018 19:40:19 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io0-f181.google.com (mail-io0-f181.google.com [209.85.223.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48F828A91D; Thu, 28 Jun 2018 19:40:19 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io0-f181.google.com with SMTP id r24-v6so6325763ioh.9; Thu, 28 Jun 2018 12:40:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=zK+nkLJl+7+gHgdXH7EDJR2rPO3S16dANddjgEClXO8=; b=PKwjPI4ytFzoOneS4wjHUwszHAJg0rty7ObBSIV2vjlbbhFgJ6Nh8MRn8FRqgawt2B OLOMqgQnuXNSla2WHBSRoxThkOQk0g9XRF+ilJ9uluggJTGyYbv5uXgQBrq85s7aKIU4 Y+cXOAb5PIwNbwhotwBoWylgK/ZkrvYwVnt6mR/vro4H9EgvOih5WlMCFjSNF7X/TJY5 gGAHb3UJTsjVBTQLnZMiNhkStS65VHAduWnI0In/Vxve0o68LClU6W4wsqN5PJcgqEZd GAGGdzVXBGBl0nTOtTg3+Tv/PXz/P4PK5K4qyfkI7CEVfCHGaQP8vGNfZiuNVf/w7bcy nDyw== X-Gm-Message-State: APt69E1wupAjV7DoHznGEZhqssr9bvHyg086BjP/4GmjqjD0feVjsEr/ 1ls9peha0x5qRaLh4gNg+J2/6DIu X-Google-Smtp-Source: AAOMgpdWjGbLkErW59bv3kyj+jDCny8+cRNj8pyoiKpwmFXNKwMxSjn9HUU35p8o+zfhB526mhuFJQ== X-Received: by 2002:a6b:ac42:: with SMTP id v63-v6mr9686827ioe.71.1530212990166; Thu, 28 Jun 2018 12:09:50 -0700 (PDT) Received: from mail-it0-f41.google.com (mail-it0-f41.google.com. [209.85.214.41]) by smtp.gmail.com with ESMTPSA id n201-v6sm3602973itb.8.2018.06.28.12.09.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 12:09:49 -0700 (PDT) Received: by mail-it0-f41.google.com with SMTP id y127-v6so158587itd.1; Thu, 28 Jun 2018 12:09:49 -0700 (PDT) X-Received: by 2002:a24:100f:: with SMTP id 15-v6mr9687541ity.61.1530212989741; Thu, 28 Jun 2018 12:09:49 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 2002:a02:7e0a:0:0:0:0:0 with HTTP; Thu, 28 Jun 2018 12:09:49 -0700 (PDT) In-Reply-To: References: <201806281701.w5SH15eP011261@repo.freebsd.org> From: Conrad Meyer Date: Thu, 28 Jun 2018 12:09:49 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r335765 - head/sys/sys To: Justin Hibbits Cc: dab@freebsd.org, src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2018 19:40:19 -0000 I think the right initializer is something like: *(kevp_) = (struct kevent) { ... .ext = { [0] = 0, [1] = 0, ... }, }; (I.e., use a C99 array static initializer to initialize the array member of struct kevent.) Best, Conrad On Thu, Jun 28, 2018 at 11:45 AM, Justin Hibbits wrote: > Hi David, > > On Thu, Jun 28, 2018 at 12:01 PM David Bright 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 >> 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 >