xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Chunyan Liu <cyliu@suse.com>
To: xen-devel@lists.xen.org
Cc: Simon Cao <caobosimon@gmail.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Chunyan Liu <cyliu@suse.com>,
	George Dunlap <george.dunlap@citrix.com>
Subject: [PATCH 3/4] cleanup redundant lstat in libxl_pvusb.c
Date: Thu,  7 Apr 2016 17:40:27 +0800	[thread overview]
Message-ID: <1460022028-25174-4-git-send-email-cyliu@suse.com> (raw)
In-Reply-To: <1460022028-25174-1-git-send-email-cyliu@suse.com>

CID: 1358112

Signed-off-by: Chunyan Liu <cyliu@suse.com>
CC: Simon Cao <caobosimon@gmail.com>
CC: George Dunlap <george.dunlap@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 tools/libxl/libxl_pvusb.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/tools/libxl/libxl_pvusb.c b/tools/libxl/libxl_pvusb.c
index 45117cf..02d3e55 100644
--- a/tools/libxl/libxl_pvusb.c
+++ b/tools/libxl/libxl_pvusb.c
@@ -983,25 +983,14 @@ static char *usbdev_busid_from_ctrlport(libxl__gc *gc, uint32_t domid,
 static int usbintf_get_drvpath(libxl__gc *gc, const char *intf, char **drvpath)
 {
     char *spath, *dp = NULL;
-    struct stat st;
-    int r;
 
     spath = GCSPRINTF(SYSFS_USB_DEV "/%s/driver", intf);
 
-    r = lstat(spath, &st);
-    if (r == 0) {
-        /* Find the canonical path to the driver. */
-        dp = libxl__zalloc(gc, PATH_MAX);
-        dp = realpath(spath, dp);
-        if (!dp) {
-            LOGE(ERROR, "get realpath failed: '%s'", spath);
-            return ERROR_FAIL;
-        }
-    } else if (errno == ENOENT) {
-        /* driver path doesn't exist */
-        dp = NULL;
-    } else {
-        LOGE(ERROR, "lstat failed: '%s'", spath);
+    /* Find the canonical path to the driver. */
+    dp = libxl__zalloc(gc, PATH_MAX);
+    dp = realpath(spath, dp);
+    if (!dp && errno != ENOENT) {
+        LOGE(ERROR, "get realpath failed: '%s'", spath);
         return ERROR_FAIL;
     }
 
-- 
2.1.4


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

  parent reply	other threads:[~2016-04-07  9:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-07  9:40 [PATCH 0/4] pvusb fixes Chunyan Liu
2016-04-07  9:40 ` [PATCH 1/4] a fix in libxl_device_usbdev_list Chunyan Liu
2016-04-07 16:45   ` Ian Jackson
2016-04-08  3:47     ` Chun Yan Liu
2016-04-08 13:28       ` Ian Jackson
2016-04-08 13:30         ` Ian Jackson
2016-04-07 16:50   ` Ian Jackson
2016-04-07  9:40 ` [PATCH 2/4] correct libxl_write_exactly sizeof Chunyan Liu
2016-04-07 16:46   ` Ian Jackson
2016-04-07  9:40 ` Chunyan Liu [this message]
2016-04-07 16:47   ` [PATCH 3/4] cleanup redundant lstat in libxl_pvusb.c Ian Jackson
2016-04-07  9:40 ` [PATCH 4/4] fix a pvusb type check Chunyan Liu
2016-04-07  9:47   ` Juergen Gross

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=1460022028-25174-4-git-send-email-cyliu@suse.com \
    --to=cyliu@suse.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=caobosimon@gmail.com \
    --cc=george.dunlap@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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).