diff mbox

[3/4] cleanup redundant lstat in libxl_pvusb.c

Message ID 1460022028-25174-4-git-send-email-cyliu@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chunyan Liu April 7, 2016, 9:40 a.m. UTC
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(-)

Comments

Ian Jackson April 7, 2016, 4:47 p.m. UTC | #1
Chunyan Liu writes ("[PATCH 3/4] cleanup redundant lstat in libxl_pvusb.c"):
> 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>

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

Although for this and the previous patch, it would have been better to
add "libxl:" to the start of the Subject.

I will fix that up as I commit.

Ian.
diff mbox

Patch

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;
     }