1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-26 03:22:12 +03:00

dmsetup: simplify check of parsed cookie value

Improving parsing error detection for strtoul.
This commit is contained in:
Zdenek Kabelac 2017-07-19 22:04:37 +02:00
parent 86d7adc2a5
commit e769e3d3bf

View File

@ -1396,15 +1396,14 @@ static uint32_t _get_cookie_value(const char *str_value)
char *p; char *p;
errno = 0; errno = 0;
if (!(value = strtoul(str_value, &p, 0)) || value = strtoul(str_value, &p, 0);
*p ||
(value == ULONG_MAX && errno == ERANGE) || if (errno || !value || (*p) || (value > UINT32_MAX)) {
value > 0xFFFFFFFF) {
err("Incorrect cookie value"); err("Incorrect cookie value");
return 0; return 0;
} }
else
return (uint32_t) value; return (uint32_t) value;
} }
static int _udevflags(CMD_ARGS) static int _udevflags(CMD_ARGS)