xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Xiong Zhang <xiong.y.zhang@intel.com>
Cc: ian.jackson@eu.citrix.com, xen-devel@lists.xensource.com,
	wei.liu2@citrix.com
Subject: Re: [PATCH 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission
Date: Fri, 30 Jun 2017 14:53:17 +0100	[thread overview]
Message-ID: <20170630135317.k5yahvmgpjqnwl2q@citrix.com> (raw)
In-Reply-To: <1498795887-23149-1-git-send-email-xiong.y.zhang@intel.com>

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@intel.com>
> ---
>  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@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-06-30 13:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-30  4:11 [PATCH 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission Xiong Zhang
2017-06-30  4:11 ` [PATCH 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID Xiong Zhang
2017-06-30 13:54   ` Wei Liu
2017-06-30 13:53 ` Wei Liu [this message]
2017-07-02 19:25 ` [PATCH v2 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission Xiong Zhang
2017-07-02 19:25   ` [PATCH v2 2/2] tools/libxl/libxl_pci.c: Judge igd through class code instead of device ID Xiong Zhang
2017-07-04 11:07   ` [PATCH v2 1/2] tools/libxl/libxl_pci.c: Extract sysfs_dev_get_class from libxl__grant_vga_iomem_permission Wei Liu
2017-07-04 11:30     ` Roger Pau Monné
2017-07-04 11:34       ` Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170630135317.k5yahvmgpjqnwl2q@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    --cc=xiong.y.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).