From: Ian Jackson Subject: Re: [PATCH 05/19] libxl: events: Use libxl__xswait_* in spawn code Date: Mon, 10 Mar 2014 10:26:11 +0000 Message-ID: <21277.37699.512687.207388@mariner.uk.xensource.com> References: <1393945016-1417-1-git-send-email-ian.jackson@eu.citrix.com> <1393945016-1417-6-git-send-email-ian.jackson@eu.citrix.com> <531D3305.3070008@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <531D3305.3070008@cn.fujitsu.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: Lai Jiangshan Cc: Shriram Rajagopalan , xen-devel@lists.xensource.com, Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Lai Jiangshan writes ("Re: [PATCH 05/19] libxl: events: Use libxl__xswait_* in spawn code"): > On 03/04/2014 10:56 PM, Ian Jackson wrote: > > Replace open-coded use of ev_time and ev_xswatch with xswait. ... > > + ss->xswait.ao = ao; > > + ss->xswait.what = GCSPRINTF("%s startup", ss->what); > > + ss->xswait.path = ss->xspath; > > + ss->xswait.timeout_ms = ss->timeout_ms; > > + ss->xswait.callback = spawn_watch_event; > > + rc = libxl__xswait_start(gc, &ss->xswait); > > This is another kind of open code, I guess it should be wrapped into > a function. I'm not sure I follow. These are, effectively, the arguments to libxl__xswait_start. libxl__xswait_start takes its "arguments" inside the xswait structure. So the LHS are formulaic but the RHS are all specific to the call site. I guess we could use GCC's compound literal syntax, with something like this: ss->xswait = (libxl__xswait_state){ .ao = ao, .what = GCSPRINTF("%s startup", ss->what), .path = ss->xspath, .timeout_ms = ss->timeout_ms, .callback = spawn_watch_event, }; But that's not an improvement IMO. Ian.