From owner-svn-src-all@freebsd.org Wed Jul 11 14:50:08 2018 Return-Path: Delivered-To: svn-src-all@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 0373B1044AF2; Wed, 11 Jul 2018 14:50:08 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AC350757CA; Wed, 11 Jul 2018 14:50:07 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 891AB141A2; Wed, 11 Jul 2018 14:50:07 +0000 (UTC) (envelope-from dab@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6BEo75p052199; Wed, 11 Jul 2018 14:50:07 GMT (envelope-from dab@FreeBSD.org) Received: (from dab@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6BEo7iZ052198; Wed, 11 Jul 2018 14:50:07 GMT (envelope-from dab@FreeBSD.org) Message-Id: <201807111450.w6BEo7iZ052198@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dab set sender to dab@FreeBSD.org using -f From: David Bright Date: Wed, 11 Jul 2018 14:50:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r336198 - stable/11/sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: dab X-SVN-Commit-Paths: stable/11/sys/sys X-SVN-Commit-Revision: 336198 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2018 14:50:08 -0000 Author: dab Date: Wed Jul 11 14:50:06 2018 New Revision: 336198 URL: https://svnweb.freebsd.org/changeset/base/336198 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 Sponsored by: Dell EMC Modified: stable/11/sys/sys/event.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/sys/event.h ============================================================================== --- stable/11/sys/sys/event.h Wed Jul 11 13:53:44 2018 (r336197) +++ stable/11/sys/sys/event.h Wed Jul 11 14:50:06 2018 (r336198) @@ -45,6 +45,21 @@ #define EVFILT_SENDFILE (-12) /* attached to sendfile requests */ #define EVFILT_SYSCOUNT 12 +#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); \ @@ -54,6 +69,7 @@ (kevp)->data = (e); \ (kevp)->udata = (f); \ } while(0) +#endif struct kevent { uintptr_t ident; /* identifier for this event */