From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH 07/15] libxl: provide libxl__xs_*_checked and libxl__xs_transaction_* Date: Wed, 30 May 2012 18:48:21 +0100 Message-ID: <1338400101.14877.24.camel@dagon.hellion.org.uk> References: <1338394606-22693-1-git-send-email-ian.jackson@eu.citrix.com> <1338394606-22693-8-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1338394606-22693-8-git-send-email-ian.jackson@eu.citrix.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 Jackson Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org > +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 && ? [...] > +int libxl__xs_transaction_start(libxl__gc *gc, xs_transaction_t *t) > +{ > + assert(!*t); > + *t = xs_transaction_start(CTX->xsh); > + if (!*t) { > + LOGE(ERROR, "could not create xenstore transaction"); > + return ERROR_FAIL; > + } > + return 0; > +} > + > +int libxl__xs_transaction_commit(libxl__gc *gc, xs_transaction_t *t) > +{ > + assert(*t); > + > + if (!xs_transaction_end(CTX->xsh, *t, 0)) { > + if (errno == EAGAIN) > + return +1; > + > + *t = 0; > + LOGE(ERROR, "could not commit xenstore transacton"); transaction It would be much more useful if this function took a "const char *what" (even just __func__ from the caller) and logged it here. To a lesser extent this applies to all these helpers. > + return ERROR_FAIL; > + } > + > + *t = 0; > + return 0; > +} > + > +void libxl__xs_transaction_abort(libxl__gc *gc, xs_transaction_t *t) > +{ > + if (!*t) > + return; > + > + if (!xs_transaction_end(CTX->xsh, *t, 1)) > + LOGE(ERROR, "could not abort xenstore transacton"); transaction > + > + *t = 0; > +}