Skip to contentSkip to conversation

bind_usbintf: do not reuse 'path'

PATCH Superseded Chunyan Liu 2 participants 3 messages Apr 7, 2016 – Apr 8, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bind_usbintf: do not reuse 'path'

To avoid confusion, add a new variable "intf_path" to indicate driver/interface path, let "path" indicate driver/bind path only.

CID: 1358111

CC Simon Cao <[email protected]>
CC George Dunlap <[email protected]>
CC Ian Jackson <[email protected]>
---
 tools/libxl/libxl_pvusb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/libxl/libxl_pvusb.c +3 -3
index 6447639..8cf3ddc 100644
@@ -1035,18 +1035,18 @@ out:
 
 static int bind_usbintf(libxl__gc *gc, const char *intf, const char *drvpath)
 {
-    char *path;
+    char *path, *intf_path;
     struct stat st;
     int fd = -1;
     int rc, r;
 
-    path = GCSPRINTF("%s/%s", drvpath, intf);
+    intf_path = GCSPRINTF("%s/%s", drvpath, intf);
 
     /* check through lstat, if intf already exists under drvpath,
      * it's already bound, return directly; if it doesn't exist,
      * continue to do bind work; otherwise, return error.
      */
-    r = lstat(path, &st);
+    r = lstat(intf_path, &st);
     if (r == 0)
         return 0;
     if (r < 0 && errno != ENOENT)
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

Chunyan Liu writes ("[PATCH] bind_usbintf: do not reuse 'path'"):

Quoted 2 lines

To avoid confusion, add a new variable "intf_path" to indicate driver/interface path, let "path" indicate driver/bind path only.

I think it would be better to rename both variables, as I suggested in my mail yesterday. That makes it much more obvious that each place where `path' was used has been checked and the reference to the proper variable substituted.

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

On 4/8/2016 at 12:52 AM, in message

<[email protected]>, Ian Jackson

Quoted 8 lines · <[email protected]> wrote:

Chunyan Liu writes ("[PATCH] bind_usbintf: do not reuse 'path'"):

Quoted 2 lines

To avoid confusion, add a new variable "intf_path" to indicate driver/interface path, let "path" indicate driver/bind path only.

I think it would be better to rename both variables, as I suggested in my mail yesterday. That makes it much more obvious that each place where `path' was used has been checked and the reference to the proper variable substituted.

Updated. Sent V2.

Quoted 5 lines

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel