From de91f88afe9c50141f681469fbed357571f1c3eb Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 22 Oct 2007 14:26:45 +0100 Subject: [PATCH] vt-d: Fix PCI=device parsing. Signed-off-by: Weidong Han --- tools/ioemu/hw/pass-through.c | 8 ++++---- tools/python/xen/lowlevel/xc/xc.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/ioemu/hw/pass-through.c b/tools/ioemu/hw/pass-through.c index b445291874..7dd9588ba0 100644 --- a/tools/ioemu/hw/pass-through.c +++ b/tools/ioemu/hw/pass-through.c @@ -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; } diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 4a2a64715e..6a2e848b0b 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -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; } -- 2.30.2