sharedmem: use 'unsigned long long' for memory region parsing

I see warnings like this:

sharedmem.c:89:44: warning: incompatible pointer types passing 'uint64_t *' (aka 'unsigned long long *') to parameter of type 'unsigned long *' [-Wincompatible-pointer-types]

Since 'unsigned long' might actually be smaller than 'uint64_t', we
should really upgrade to 'unsigned long long' parsing.

At the same time, the existing error handling was wrong: it should have
been looking for ULONG_MAX (per the man page). Convert that to
ULLONG_MAX to fix that bug while we're at it.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
This commit is contained in:
Brian Norris 2018-07-02 09:51:51 -07:00 committed by Bjorn Andersson
parent 5eb67a1fb5
commit 577aedad06

View File

@ -23,9 +23,9 @@ struct rmtfs_mem {
};
static int parse_hex_sysattr(struct udev_device *dev, const char *name,
unsigned long *value)
uint64_t *value)
{
unsigned long val;
unsigned long long val;
const char *buf;
char *endptr;
@ -34,8 +34,8 @@ static int parse_hex_sysattr(struct udev_device *dev, const char *name,
return -ENOENT;
errno = 0;
val = strtoul(buf, &endptr, 16);
if ((val == LONG_MAX && errno == ERANGE) || endptr == buf) {
val = strtoull(buf, &endptr, 16);
if ((val == ULLONG_MAX && errno == ERANGE) || endptr == buf) {
return -errno;
}