vt-d: Fix PCI=device parsing.
authorKeir Fraser <keir@xensource.com>
Mon, 22 Oct 2007 13:26:45 +0000 (14:26 +0100)
committerKeir Fraser <keir@xensource.com>
Mon, 22 Oct 2007 13:26:45 +0000 (14:26 +0100)
Signed-off-by: Weidong Han <weidong.han@intel.com>
tools/ioemu/hw/pass-through.c
tools/python/xen/lowlevel/xc/xc.c

index b44529187437fb31474e905ebf633b63e1e58983..7dd9588ba080ee7e7154fa6b81a6383895616a44 100644 (file)
@@ -39,11 +39,10 @@ static int next_bdf(char **str, int *seg, int *bus, int *dev, int *func)
 {
     char *token;
 
-    token = strchr(*str, ',');
-    if ( !token )
+    if ( !(*str) || !strchr(*str, ',') )
         return 0;
-    token++;
 
+    token = *str;
     *seg  = token_value(token);
     token = strchr(token, ',') + 1;
     *bus  = token_value(token);
@@ -51,8 +50,9 @@ static int next_bdf(char **str, int *seg, int *bus, int *dev, int *func)
     *dev  = token_value(token);
     token = strchr(token, ',') + 1;
     *func  = token_value(token);
+    token = strchr(token, ',');
+    *str = token ? token + 1 : NULL;
 
-    *str = token;
     return 1;
 }
 
index 4a2a64715ef6c163e1b22b36fb51fb62837d1426..6a2e848b0bb8b68d98aeabee185c576ffc49acd0 100644 (file)
@@ -543,11 +543,10 @@ static int next_bdf(char **str, int *seg, int *bus, int *dev, int *func)
 {
     char *token;
 
-    token = strchr(*str, ',');
-    if ( !token )
+    if ( !(*str) || !strchr(*str, ',') )
         return 0;
-    token++;
 
+    token = *str;
     *seg  = token_value(token);
     token = strchr(token, ',') + 1;
     *bus  = token_value(token);
@@ -555,8 +554,9 @@ static int next_bdf(char **str, int *seg, int *bus, int *dev, int *func)
     *dev  = token_value(token);
     token = strchr(token, ',') + 1;
     *func  = token_value(token);
+    token = strchr(token, ',');
+    *str = token ? token + 1 : NULL;
 
-    *str = token;
     return 1;
 }