diff mbox

[01/10] libxl_pci: improve return codes for more xl commands

Message ID 1459514413-18682-2-git-send-email-paulinaszubarczyk@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Paulina Szubarczyk April 1, 2016, 12:40 p.m. UTC
Retrun error code instead of allways 0. Remove assigned-only
ret variable.

Signed-off-by: Paulina Szubarczyk <paulinaszubarczyk@gmail.com>
---
 tools/libxl/libxl_pci.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Roger Pau Monné April 1, 2016, 2 p.m. UTC | #1
On Fri, 1 Apr 2016, Paulina Szubarczyk wrote:
> Retrun error code instead of allways 0. Remove assigned-only
     ^ ur                       ^ extra "l"
> ret variable.
> 
> Signed-off-by: Paulina Szubarczyk <paulinaszubarczyk@gmail.com>

You have missed to Cc one of the maintainers of the code, Ian Jackson. 
Please either check the top-level MAINTAINERS file manually, or run 
scripts/get_maintainer.pl against the patches.

In general the patch LGTM, just a couple of comments.

> ---
>  tools/libxl/libxl_pci.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
> index dc10cb7..3435ce2 100644
> --- a/tools/libxl/libxl_pci.c
> +++ b/tools/libxl/libxl_pci.c
> @@ -84,13 +84,11 @@ int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid,
>      flexarray_t *front = NULL;
>      flexarray_t *back = NULL;
>      libxl__device device;
> -    int ret = ERROR_NOMEM, i;
> +    int i;
>  
>      front = flexarray_make(gc, 16, 1);
>      back = flexarray_make(gc, 16, 1);
>  
> -    ret = 0;
> -
>      LOG(DEBUG, "Creating pci backend");
>
>      /* add pci device */

There's a call to libxl__device_from_pcidev here that returns a value 
(although it's always 0 right now). Either make that function return void, 
or check the return value for errors.

> @@ -108,12 +106,10 @@ int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid,
>      flexarray_append_pair(front, "backend-id", GCSPRINTF("%d", 0));
>      flexarray_append_pair(front, "state", GCSPRINTF("%d", XenbusStateInitialising));
>  
> -    libxl__device_generic_add(gc, XBT_NULL, &device,
> +    return libxl__device_generic_add(gc, XBT_NULL, &device,
>                                libxl__xs_kvs_of_flexarray(gc, back, back->count),
>                                libxl__xs_kvs_of_flexarray(gc, front, front->count),
>                                NULL);

You should indent those line to match the start of the parentheses.

Roger.
diff mbox

Patch

diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index dc10cb7..3435ce2 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -84,13 +84,11 @@  int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid,
     flexarray_t *front = NULL;
     flexarray_t *back = NULL;
     libxl__device device;
-    int ret = ERROR_NOMEM, i;
+    int i;
 
     front = flexarray_make(gc, 16, 1);
     back = flexarray_make(gc, 16, 1);
 
-    ret = 0;
-
     LOG(DEBUG, "Creating pci backend");
 
     /* add pci device */
@@ -108,12 +106,10 @@  int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid,
     flexarray_append_pair(front, "backend-id", GCSPRINTF("%d", 0));
     flexarray_append_pair(front, "state", GCSPRINTF("%d", XenbusStateInitialising));
 
-    libxl__device_generic_add(gc, XBT_NULL, &device,
+    return libxl__device_generic_add(gc, XBT_NULL, &device,
                               libxl__xs_kvs_of_flexarray(gc, back, back->count),
                               libxl__xs_kvs_of_flexarray(gc, front, front->count),
                               NULL);
-
-    return 0;
 }
 
 static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, int starting)