]> sourceware.org Git - lvm2.git/commitdiff
dmsetup: simplify check of parsed cookie value
authorZdenek Kabelac <zkabelac@redhat.com>
Wed, 19 Jul 2017 20:04:37 +0000 (22:04 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Thu, 20 Jul 2017 09:18:16 +0000 (11:18 +0200)
Improving parsing error detection for strtoul.

tools/dmsetup.c

index 2eed39e3c9566ad5b77058acf6f1b08c617e8471..69649ae192cf17763bad086ebf673a7609735ff3 100644 (file)
@@ -1396,15 +1396,14 @@ static uint32_t _get_cookie_value(const char *str_value)
        char *p;
 
        errno = 0;
-       if (!(value = strtoul(str_value, &p, 0)) ||
-           *p ||
-           (value == ULONG_MAX && errno == ERANGE) ||
-           value > 0xFFFFFFFF) {
+       value = strtoul(str_value, &p, 0);
+
+       if (errno || !value || (*p) || (value > UINT32_MAX)) {
                err("Incorrect cookie value");
                return 0;
        }
-       else
-               return (uint32_t) value;
+
+       return (uint32_t) value;
 }
 
 static int _udevflags(CMD_ARGS)
This page took 0.040884 seconds and 5 git commands to generate.