From: Ian Jackson Subject: Re: [PATCH 07/15] libxl: provide libxl__xs_*_checked and libxl__xs_transaction_* Date: Thu, 31 May 2012 11:22:40 +0100 Message-ID: <20423.18032.316476.341196@mariner.uk.xensource.com> References: <1338394606-22693-1-git-send-email-ian.jackson@eu.citrix.com> <1338394606-22693-8-git-send-email-ian.jackson@eu.citrix.com> <1338400101.14877.24.camel@dagon.hellion.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1338400101.14877.24.camel@dagon.hellion.org.uk> 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 ("Re: [Xen-devel] [PATCH 07/15] libxl: provide libxl__xs_*_checked and libxl__xs_transaction_*"): > > > +int libxl__xs_read_checked(libxl__gc *gc, xs_transaction_t t, > > + const char *path, const char **result_out) > > +{ > > + char *result = libxl__xs_read(gc, t, path); > > + if (!result) { > > + if (errno != ENOENT) { > > Can't you combine these with && ? Yes, but this matches better the way I think of it. I can change it if you like. > > +int libxl__xs_transaction_commit(libxl__gc *gc, xs_transaction_t *t) > > +{ ... > > + LOGE(ERROR, "could not commit xenstore transacton"); > > transaction Oops. > It would be much more useful if this function took a "const char > *what" (even just __func__ from the caller) and logged it here. I think that this call can only fail due to general failure of xenstore (or our xenstore handle). So a `what' here wouldn't help much. The other helpers are more likely to fail (permissions, for example) but they can log the path. I played about a bit with adding more information supplied by the callers. Ultimately what I seem to end up with is something that's rather too clumsy to use without helper macros which I don't think will assist with clarity. Eg, if (got) { const char *got_ret; rc = XLXS_READ(t, lds->ret_path, &got_ret); if (rc) goto out; which is all very well but hardly a model of clarity. An alternative would be to replace `xs_transaction_t t' with a struct that contains at least the file and function name and a `what', which would be passed to the transaction start helper. So I think I would prefer to keep things as they are. Ian.