1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-09 18:03:17 +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;
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)