From: Muli Ben-Yehuda Subject: Re: [Xen-changelog] Make it possible to run valgrind on code linked with the libxc libraries. Date: Tue, 22 Nov 2005 21:47:55 +0200 Message-ID: <20051122194755.GC28786@granada.merseine.nu> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT Return-path: In-reply-to: Content-disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: emellor@xensource.com List-Id: xen-devel@lists.xenproject.org On Tue, Nov 22, 2005 at 06:20:06PM +0000, Xen patchbot -unstable wrote: > diff -r c1c8da6f2afe -r 602aefe7bd48 tools/libxc/xg_private.h > --- a/tools/libxc/xg_private.h Mon Nov 21 18:08:44 2005 > +++ b/tools/libxc/xg_private.h Tue Nov 22 15:31:16 2005 > @@ -15,6 +15,16 @@ > > #include > #include > + > +/* valgrind cannot see when a hypercall has filled in some values. For this > + reason, we must zero the dom0_op_t instance before a call, if using > + valgrind. */ > +#ifdef VALGRIND > +#define DECLARE_DOM0_OP dom0_op_t op; memset(&op, 0, sizeof(op)) > +#else > +#define DECLARE_DOM0_OP dom0_op_t op > +#endif This is pretty ugly IMHO. Also, if someone does if (foo) bla; else DECLARE_DOM0_OP; it breaks. Is the micro-optimization of not initializing the structures to 0 worth it? I really doubt it. But if yes, please at least do something like #ifdef VALGRIND #define DECLARE_DOM0_OP(name) dom0_op_t name = { .cmd = 0, .interface_version = 0, .pad = { 0 } } #else #define #define DECLARE_DOM0_OP(name) dom0_op_t name; #endif Cheers, Muli -- Muli Ben-Yehuda http://www.mulix.org | http://mulix.livejournal.com/