]> mj.ucw.cz Git - pciutils.git/blobdiff - setpci.c
Added helper macros BITS and TABLE
[pciutils.git] / setpci.c
index 5f8f658e846838d70edc1781d2397435dcc6dbbe..97740e8c2168c0c3f534b57571a7501a8f15c49c 100644 (file)
--- a/setpci.c
+++ b/setpci.c
@@ -374,10 +374,15 @@ parse_options(int argc, char **argv)
       if (!strcmp(argv[1], "--help"))
        usage();
       if (!strcmp(argv[1], "--version"))
-       puts("setpci version " PCIUTILS_VERSION);
+       {
+         puts("setpci version " PCIUTILS_VERSION);
+         exit(0);
+       }
       if (!strcmp(argv[1], "--dumpregs"))
-       dump_registers();
-      exit(0);
+       {
+         dump_registers();
+         exit(0);
+       }
     }
 
   while (i < argc && argv[i][0] == '-')
@@ -494,7 +499,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)
@@ -625,13 +634,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);