]> mj.ucw.cz Git - pciutils.git/blobdiff - setpci.c
lspci: Clarify "PCIe-to-PCI/PCI-X" desc and Bridge Retry Config Enable
[pciutils.git] / setpci.c
index 21858bdfdddec8be1a9f674bdd777b1d88b2c32f..acf768971702edcaff5d9e14c28eb18268f6669d 100644 (file)
--- a/setpci.c
+++ b/setpci.c
@@ -10,7 +10,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdarg.h>
-#include <unistd.h>
 #include <errno.h>
 
 #define PCIUTILS_SETPCI
 #include <errno.h>
 
 #define PCIUTILS_SETPCI
@@ -482,11 +481,12 @@ static const struct reg_name *parse_reg_name(char *name)
 static int parse_x32(char *c, char **stopp, unsigned int *resp)
 {
   char *stop;
 static int parse_x32(char *c, char **stopp, unsigned int *resp)
 {
   char *stop;
+  unsigned long int l;
 
   if (!*c)
     return -1;
   errno = 0;
 
   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)
   if (errno)
     return -1;
   if ((l & ~0U) != l)
@@ -499,7 +499,11 @@ static int parse_x32(char *c, char **stopp, unsigned int *resp)
       return 0;
     }
   else
       return 0;
     }
   else
-    return 1;
+    {
+      if (stopp)
+       *stopp = NULL;
+      return 1;
+    }
 }
 
 static void parse_register(struct op *op, char *base)
 }
 
 static void parse_register(struct op *op, char *base)
@@ -633,14 +637,14 @@ static void parse_op(char *c, struct pci_dev **selected_devices)
       if (parse_x32(value, &f, &ll) < 0 || f && *f != ':')
        parse_err("Invalid value \"%s\"", value);
       lim = max_values[op->width];
       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)
+      if (ll > lim && ll < ~0U - lim)
        parse_err("Value \"%s\" is out of range", value);
       op->values[j].value = ll;
       if (f && *f == ':')
        {
          if (parse_x32(f+1, NULL, &ll) <= 0)
            parse_err("Invalid mask \"%s\"", f+1);
        parse_err("Value \"%s\" is out of range", value);
       op->values[j].value = ll;
       if (f && *f == ':')
        {
          if (parse_x32(f+1, NULL, &ll) <= 0)
            parse_err("Invalid mask \"%s\"", f+1);
-         if (ll > lim && ll < ~0UL - lim)
+         if (ll > lim && ll < ~0U - lim)
            parse_err("Mask \"%s\" is out of range", f+1);
          op->values[j].mask = ll;
          op->values[j].value &= ll;
            parse_err("Mask \"%s\" is out of range", f+1);
          op->values[j].mask = ll;
          op->values[j].value &= ll;