From: Ian Jackson Subject: Re: [PATCH] libxl: Enable -Wshadow Date: Fri, 14 Sep 2012 15:42:20 +0100 Message-ID: <20563.16972.124870.221950@mariner.uk.xensource.com> References: <58ab3fb73d13e250f334.1347620998@cosworth.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <58ab3fb73d13e250f334.1347620998@cosworth.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("[PATCH] libxl: Enable -Wshadow"): > libxl: Enable -Wshadow. Oh I just thought of this: > diff -r 0547430886c5 -r 58ab3fb73d13 tools/libxc/xenctrl.h > --- a/tools/libxc/xenctrl.h Fri Sep 14 11:00:40 2012 +0100 > +++ b/tools/libxc/xenctrl.h Fri Sep 14 12:09:43 2012 +0100 > @@ -236,10 +236,10 @@ typedef struct xc_hypercall_buffer xc_hy > * Returns the hypercall_buffer associated with a variable. > */ > #define HYPERCALL_BUFFER(_name) \ > - ({ xc_hypercall_buffer_t _val1; \ > - typeof(XC__HYPERCALL_BUFFER_NAME(_name)) *_val2 = &XC__HYPERCALL_BUFFER_NAME(_name); \ > - (void)(&_val1 == _val2); \ > - (_val2)->param_shadow ? (_val2)->param_shadow : (_val2); \ > + ({ xc_hypercall_buffer_t _buf1; \ > + typeof(XC__HYPERCALL_BUFFER_NAME(_name)) *_buf2 = &XC__HYPERCALL_BUFFER_NAME(_name); \ > + (void)(&_buf1 == _buf2); \ > + (_buf2)->param_shadow ? (_buf2)->param_shadow : (_buf2); \ > }) This should be something like > + ({ xc_hypercall_buffer_t _hcbuf_buf1; surely ? As there is (and can be) no reasonable rule requiring users of this macro to avoid using the name _val1 or whatever. If we're doing -Wshadow then macros which introduce local variables like this should give them names qualified somehow for the macro. Ian.