Broken by commit c4a8ca71b10eb adding the reset option. Instead of altering a const string move the while loop into an else clause. --- tools/virsh.c | 110 ++++++++++++++++++++++++++++----------------------------- 1 files changed, 54 insertions(+), 56 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index e04c9fc..0e9efad 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -3000,7 +3000,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd) int cpumaplen; int i, cpu, lastcpu, maxcpu; bool unuse = false; - char *cur; + const char *cur; int config = vshCommandOptBool(cmd, "config"); int live = vshCommandOptBool(cmd, "live"); int current = vshCommandOptBool(cmd, "current"); @@ -3061,72 +3061,70 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd) cpumap = vshCalloc(ctl, 0, cpumaplen); /* Parse cpulist */ - cur = cpulist; - if (*cur == 0) { + if (*cpulist == '\0') { goto parse_error; - } else if (*cur == 'r') { + } else if (*cpulist == 'r') { for (cpu = 0; cpu < maxcpu; cpu++) VIR_USE_CPU(cpumap, cpu); - *cur = 0; - } - - while (*cur != 0) { - - /* the char '^' denotes exclusive */ - if (*cur == '^') { - cur++; - unuse = true; - } - - /* parse physical CPU number */ - if (!c_isdigit(*cur)) - goto parse_error; - cpu = virParseNumber(&cur); - if (cpu < 0) { - goto parse_error; - } - if (cpu >= maxcpu) { - vshError(ctl, _("Physical CPU %d doesn't exist."), cpu); - goto parse_error; - } - virSkipSpaces(&cur); - - if ((*cur == ',') || (*cur == 0)) { - if (unuse) { - VIR_UNUSE_CPU(cpumap, cpu); - } else { - VIR_USE_CPU(cpumap, cpu); + } else { + cur = cpulist; + while (*cur != '\0') { + /* the char '^' denotes exclusive */ + if (*cur == '^') { + cur++; + unuse = true; } - } else if (*cur == '-') { - /* the char '-' denotes range */ - if (unuse) { + + /* parse physical CPU number */ + if (!c_isdigit(*cur)) goto parse_error; - } - cur++; - virSkipSpaces(&cur); - /* parse the end of range */ - lastcpu = virParseNumber(&cur); - if (lastcpu < cpu) { + cpu = virParseNumber(&cur); + if (cpu < 0) { goto parse_error; } - if (lastcpu >= maxcpu) { - vshError(ctl, _("Physical CPU %d doesn't exist."), maxcpu); + if (cpu >= maxcpu) { + vshError(ctl, _("Physical CPU %d doesn't exist."), cpu); goto parse_error; } - for (i = cpu; i <= lastcpu; i++) { - VIR_USE_CPU(cpumap, i); - } virSkipSpaces(&cur); - } - if (*cur == ',') { - cur++; - virSkipSpaces(&cur); - unuse = false; - } else if (*cur == 0) { - break; - } else { - goto parse_error; + if ((*cur == ',') || (*cur == '\0')) { + if (unuse) { + VIR_UNUSE_CPU(cpumap, cpu); + } else { + VIR_USE_CPU(cpumap, cpu); + } + } else if (*cur == '-') { + /* the char '-' denotes range */ + if (unuse) { + goto parse_error; + } + cur++; + virSkipSpaces(&cur); + /* parse the end of range */ + lastcpu = virParseNumber(&cur); + if (lastcpu < cpu) { + goto parse_error; + } + if (lastcpu >= maxcpu) { + vshError(ctl, _("Physical CPU %d doesn't exist."), maxcpu); + goto parse_error; + } + for (i = cpu; i <= lastcpu; i++) { + VIR_USE_CPU(cpumap, i); + } + virSkipSpaces(&cur); + } + + if (*cur == ',') { + cur++; + virSkipSpaces(&cur); + unuse = false; + } else if (*cur == '\0') { + break; + } else { + goto parse_error; + } } } -- 1.7.0.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list