From: Tim Deegan Subject: Re: [PATCH v2] RFC: Automatically check xen's public headers for C++ pitfalls. Date: Thu, 5 Mar 2015 12:25:57 +0100 Message-ID: <20150305112557.GC86322@deinos.phlegethon.org> References: <1424956264-15271-1-git-send-email-tim@xen.org> <1424967096-6105-1-git-send-email-tim@xen.org> <20150226162842.GG43832@deinos.phlegethon.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20150226162842.GG43832@deinos.phlegethon.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Keir Fraser , Ian Jackson , Ian Campbell , Jan Beulich List-Id: xen-devel@lists.xenproject.org At 17:28 +0100 on 26 Feb (1424968122), Tim Deegan wrote: > BTW, ring.h is the only instance of that, so the extra diff to clear > that up too is pretty small (see below). > > Not sure what people think about that though - it might be > quite a PITA for downstream users of it, though they ought really to > be using local copies so they can update in a controlled way. So I've seen four responses in favour of just renaming the field (Andrew Cooper, Razvan Cojocaru, Don Slutz and David Vrabel) and one in favour of #ifdeffing it so it's only renamed in C++ (Jan Beulich). I really don't like adding more #ifdefs to an already hard-to-read file; I'd rather just rename the field, or else leaving it alone and letting C++ users carry the fixup in their own code. CC'ing the other "THE REST" maintainers for their opinions. Tim. > diff --git a/xen/include/Makefile b/xen/include/Makefile > index d48a642..c7a1d52 100644 > --- a/xen/include/Makefile > +++ b/xen/include/Makefile > @@ -104,8 +104,7 @@ headers.chk: $(PUBLIC_ANSI_HEADERS) Makefile > headers++.chk: $(PUBLIC_HEADERS) Makefile > if $(CXX) -v >/dev/null 2>&1; then \ > for i in $(filter %.h,$^); do \ > - $(CXX) -x c++ -std=gnu++98 -Wall -Werror \ > - -D__XEN_TOOLS__ -Dprivate=private_is_a_keyword_in_cpp \ > + $(CXX) -x c++ -std=gnu++98 -Wall -Werror -D__XEN_TOOLS__ \ > -include stdint.h -include public/xen.h \ > -S -o /dev/null $$i || exit 1; \ > echo $$i; \ > diff --git a/xen/include/public/io/ring.h b/xen/include/public/io/ring.h > index 73e13d7..bb13494 100644 > --- a/xen/include/public/io/ring.h > +++ b/xen/include/public/io/ring.h > @@ -111,7 +111,7 @@ struct __name##_sring { \ > uint8_t msg; \ > } tapif_user; \ > uint8_t pvt_pad[4]; \ > - } private; \ > + } local; \ > uint8_t __pad[44]; \ > union __name##_sring_entry ring[1]; /* variable-length */ \ > }; \ > @@ -156,7 +156,7 @@ typedef struct __name##_back_ring __name##_back_ring_t > #define SHARED_RING_INIT(_s) do { \ > (_s)->req_prod = (_s)->rsp_prod = 0; \ > (_s)->req_event = (_s)->rsp_event = 1; \ > - (void)memset((_s)->private.pvt_pad, 0, sizeof((_s)->private.pvt_pad)); \ > + (void)memset((_s)->local.pvt_pad, 0, sizeof((_s)->local.pvt_pad)); \ > (void)memset((_s)->__pad, 0, sizeof((_s)->__pad)); \ > } while(0) > > >