[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 && ?

[...]
> +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;
> +}


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.