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

[Xen-devel] [PATCH v4 5/7] libxl: improve return codes for some pci related functions



*libxl__device_from_pcidev(), pcidev_struct_fill() initialize
 the values of libxl_device and libxl_device_pci structs
 and can be void.

*libxl__create_pci_backend(), libxl__device_pci_destroy_all()
 should propagate the success/error, rather than always returning 0.

Signed-off-by: Paulina Szubarczyk <paulinaszubarczyk@xxxxxxxxx>
---
Changed since v3:
 - pcidev_struct_fill() is now void
 - corrected indention
  
 tools/libxl/libxl_pci.c | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index ce8d763..4e2f56e 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -36,7 +36,7 @@ static unsigned int pcidev_encode_bdf(libxl_device_pci 
*pcidev)
     return value;
 }
 
-static int pcidev_struct_fill(libxl_device_pci *pcidev, unsigned int domain,
+static void pcidev_struct_fill(libxl_device_pci *pcidev, unsigned int domain,
                                unsigned int bus, unsigned int dev,
                                unsigned int func, unsigned int vdevfn)
 {
@@ -45,7 +45,6 @@ static int pcidev_struct_fill(libxl_device_pci *pcidev, 
unsigned int domain,
     pcidev->dev = dev;
     pcidev->func = func;
     pcidev->vdevfn = vdevfn;
-    return 0;
 }
 
 static void libxl_create_pci_backend_device(libxl__gc *gc, flexarray_t *back, 
int num, libxl_device_pci *pcidev)
@@ -64,9 +63,9 @@ static void libxl_create_pci_backend_device(libxl__gc *gc, 
flexarray_t *back, in
     flexarray_append_pair(back, GCSPRINTF("state-%d", num), GCSPRINTF("%d", 
XenbusStateInitialising));
 }
 
-static int libxl__device_from_pcidev(libxl__gc *gc, uint32_t domid,
-                                     libxl_device_pci *pcidev,
-                                     libxl__device *device)
+static void libxl__device_from_pcidev(libxl__gc *gc, uint32_t domid,
+                                      libxl_device_pci *pcidev,
+                                      libxl__device *device)
 {
     device->backend_devid = 0;
     device->backend_domid = 0;
@@ -74,8 +73,6 @@ static int libxl__device_from_pcidev(libxl__gc *gc, uint32_t 
domid,
     device->devid = 0;
     device->domid = domid;
     device->kind = LIBXL__DEVICE_KIND_PCI;
-
-    return 0;
 }
 
 int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid,
@@ -84,13 +81,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 +103,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,
-                              libxl__xs_kvs_of_flexarray(gc, back, 
back->count),
-                              libxl__xs_kvs_of_flexarray(gc, front, 
front->count),
-                              NULL);
-
-    return 0;
+    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);
 }
 
 static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, 
libxl_device_pci *pcidev, int starting)
@@ -1612,7 +1605,7 @@ int libxl__device_pci_destroy_all(libxl__gc *gc, uint32_t 
domid)
     }
 
     free(pcidevs);
-    return 0;
+    return rc;
 }
 
 int libxl__grant_vga_iomem_permission(libxl__gc *gc, const uint32_t domid,
-- 
1.9.1


_______________________________________________
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®.