path: root/xtables.c
diff options
authorJan Engelhardt <>2011-05-24 02:30:23 +0200
committerJan Engelhardt <>2011-05-24 14:54:27 +0200
commit0b7a140944738d67b9c4e6f09992c8407eefb18a (patch)
tree8b822c215ba1f70c41829c0a9f249d48b61233f8 /xtables.c
parent5e35b7d435c5bc1b3641f76a6601a55d32d63ac8 (diff)
libxtables: use uintmax for xtables_strtoul
Addendum to 2305d5fb42fc059f38fc1bdf53411dbeecdb310b. I noticed that unsigned long long is not consistently used, for example, min/max are still just unsigned long, and strtoul is being called. Instead of changing it to unsigned long long, just use uintmax functions right away so this does not need size-related changing in the future. Cc: JP Abgrall <> Signed-off-by: Jan Engelhardt <>
Diffstat (limited to 'xtables.c')
1 files changed, 6 insertions, 5 deletions
diff --git a/xtables.c b/xtables.c
index e11a77ee..acfcf8bd 100644
--- a/xtables.c
+++ b/xtables.c
@@ -18,6 +18,7 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <netdb.h>
#include <stdarg.h>
#include <stdbool.h>
@@ -426,10 +427,10 @@ int xtables_load_ko(const char *modprobe, bool quiet)
* Returns true/false whether number was accepted. On failure, *value has
* undefined contents.
-bool xtables_strtoul(const char *s, char **end, unsigned long long *value,
- unsigned long min, unsigned long max)
+bool xtables_strtoul(const char *s, char **end, uintmax_t *value,
+ uintmax_t min, uintmax_t max)
- unsigned long v;
+ uintmax_t v;
const char *p;
char *my_end;
@@ -439,7 +440,7 @@ bool xtables_strtoul(const char *s, char **end, unsigned long long *value,
if (*p == '-')
return false;
- v = strtoul(s, &my_end, 0);
+ v = strtoumax(s, &my_end, 0);
if (my_end == s)
return false;
if (end != NULL)
@@ -459,7 +460,7 @@ bool xtables_strtoul(const char *s, char **end, unsigned long long *value,
bool xtables_strtoui(const char *s, char **end, unsigned int *value,
unsigned int min, unsigned int max)
- unsigned long long v;
+ uintmax_t v;
bool ret;
ret = xtables_strtoul(s, end, &v, min, max);