X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=setpci.c;h=5711e5105a9d49ab107c1cff3d82140d0da8f054;hb=e2864327195d067728dd904f8ff72959c8097508;hp=55212853a9a84709ed6e0d512998f145c03322f4;hpb=1c7f2b08e95ead73368299d080c81347baa45604;p=pciutils.git diff --git a/setpci.c b/setpci.c index 5521285..5711e51 100644 --- a/setpci.c +++ b/setpci.c @@ -482,11 +482,12 @@ static const struct reg_name *parse_reg_name(char *name) static int parse_x32(char *c, char **stopp, unsigned int *resp) { char *stop; + unsigned long int l; if (!*c) return -1; errno = 0; - unsigned long int l = strtoul(c, &stop, 16); + l = strtoul(c, &stop, 16); if (errno) return -1; if ((l & ~0U) != l) @@ -499,7 +500,11 @@ static int parse_x32(char *c, char **stopp, unsigned int *resp) return 0; } else - return 1; + { + if (stopp) + *stopp = NULL; + return 1; + } } static void parse_register(struct op *op, char *base) @@ -630,13 +635,13 @@ static void parse_op(char *c, struct pci_dev **selected_devices) e = strchr(value, ','); if (e) *e++ = 0; - if (parse_x32(value, &f, &ll) < 0 || *f && *f != ':') + if (parse_x32(value, &f, &ll) < 0 || f && *f != ':') parse_err("Invalid value \"%s\"", value); lim = max_values[op->width]; if (ll > lim && ll < ~0UL - lim) parse_err("Value \"%s\" is out of range", value); op->values[j].value = ll; - if (*f == ':') + if (f && *f == ':') { if (parse_x32(f+1, NULL, &ll) <= 0) parse_err("Invalid mask \"%s\"", f+1);