From 577aedad0680c03ba2ff49d53a6b621a022dc979 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 2 Jul 2018 09:51:51 -0700 Subject: [PATCH] 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 --- sharedmem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sharedmem.c b/sharedmem.c index 9b7d762..331b616 100644 --- a/sharedmem.c +++ b/sharedmem.c @@ -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; }