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

Re: [Xen-devel] [PATCH 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission



On Fri, Jun 30, 2017 at 12:11:26PM +0800, Xiong Zhang wrote:

It would be better in the future you say "No functional change" here.

> Signed-off-by: Xiong Zhang <xiong.y.zhang@xxxxxxxxx>
> ---
>  tools/libxl/libxl_pci.c | 45 +++++++++++++++++++++++++++------------------
>  1 file changed, 27 insertions(+), 18 deletions(-)
> 
> diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
> index b14df16..cefd7d8 100644
> --- a/tools/libxl/libxl_pci.c
> +++ b/tools/libxl/libxl_pci.c
> @@ -531,6 +531,32 @@ static uint16_t sysfs_dev_get_device(libxl__gc *gc, 
> libxl_device_pci *pcidev)
>      return pci_device_device;
>  }
>  
> +static int sysfs_dev_get_class(libxl__gc *gc, libxl_device_pci *pcidev,
> +                               unsigned long *class)
> +{
> +    char *pci_device_class_path = GCSPRINTF(SYSFS_PCI_DEV"/"PCI_BDF"/class",
> +                     pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
> +    int read_items;
> +
> +    FILE *f = fopen(pci_device_class_path, "r");
> +    if (!f) {
> +        LOGE(ERROR,
> +             "pci device "PCI_BDF" does not have class attribute",
> +             pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
> +        return ERROR_FAIL;
> +    }
> +    read_items = fscanf(f, "0x%lx\n", class);
> +    fclose(f);
> +    if (read_items != 1) {
> +        LOGE(ERROR,
> +             "cannot read class of pci device "PCI_BDF,
> +             pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
> +        return ERROR_FAIL;
> +    }
> +

Please use "goto out" style error handling.

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

 


Rackspace

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