[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 10/10] libxl: libxl_tmem functions improving coding style
On Fri, 1 Apr 2016, Paulina Szubarczyk wrote: > In accordance with CODING_SYTLE: > - Use 'r' for return values to functions whose return values are a > different error space (like xc_tmem_control, xc_tmem_auth) > > Signed-off-by: Paulina Szubarczyk <paulinaszubarczyk@xxxxxxxxx> > --- > tools/libxl/libxl.c | 58 > ++++++++++++++++++++++++++--------------------------- > 1 file changed, 29 insertions(+), 29 deletions(-) > > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > index 6bb2f82..5794ade 100644 > --- a/tools/libxl/libxl.c > +++ b/tools/libxl/libxl.c > @@ -6107,14 +6107,14 @@ uint32_t libxl_vm_get_start_time(libxl_ctx *ctx, > uint32_t domid) > > char *libxl_tmem_list(libxl_ctx *ctx, uint32_t domid, int use_long) > { > - int rc; > + int r; > char _buf[32768]; > GC_INIT(ctx); > > - rc = xc_tmem_control(ctx->xch, -1, XEN_SYSCTL_TMEM_OP_LIST, domid, > 32768, use_long, > + r = xc_tmem_control(ctx->xch, -1, XEN_SYSCTL_TMEM_OP_LIST, domid, 32768, > use_long, > _buf); > - if (rc < 0) { > - LOGEV(ERROR, rc, "Can not get tmem list"); > + if (r < 0) { > + LOGEV(ERROR, r, "Can not get tmem list"); > GC_FREE; > return NULL; > } > @@ -6125,36 +6125,36 @@ char *libxl_tmem_list(libxl_ctx *ctx, uint32_t domid, > int use_long) > > int libxl_tmem_freeze(libxl_ctx *ctx, uint32_t domid) > { > - int rc; > + int r; > GC_INIT(ctx); > > - rc = xc_tmem_control(ctx->xch, -1, XEN_SYSCTL_TMEM_OP_FREEZE, domid, 0, > 0, > + r = xc_tmem_control(ctx->xch, -1, XEN_SYSCTL_TMEM_OP_FREEZE, domid, 0, 0, > NULL); > - if (rc < 0) { > - LOGEV(ERROR, rc, "Can not freeze tmem pools"); > + if (r < 0) { > + LOGEV(ERROR, r, "Can not freeze tmem pools"); > GC_FREE; > return ERROR_FAIL; > } > > GC_FREE; > - return rc; > + return r; This is conceptually wrong IMHO, you are returning an error code that's not in libxl space from a libxl function (although due to the "return" above this is always going to be 0). I would just return 0 here, or add an "out" label, keep rc and set it in the error case above replacing the return with a goto out. Roger. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |