From 714608316e4dd6216c68b663666e98962b6a8bae Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Sun, 15 Oct 2017 19:20:34 +0000 Subject: [PATCH] Use the proper type for rlim_t, fixing build failure on x32. Assuming a particular width of a type (or equivalence with "long") doesn't work everywhere. On new architectures, LFS/etc is enabled by default, making rlim_t same as rlim64_t even if long is only 32-bit. Not sure how you handle too big values -- you may want to re-check the strtoull part. Signed-off-by: Adam Borowski --- src/lxc/confile.c | 2 +- src/lxc/confile_legacy.c | 2 +- src/lxc/confile_utils.c | 4 ++-- src/lxc/confile_utils.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 4850e4ce5..3567525da 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -1453,7 +1453,7 @@ static int set_config_prlimit(const char *key, const char *value, { struct lxc_list *iter; struct rlimit limit; - unsigned long limit_value; + rlim_t limit_value; struct lxc_list *limlist = NULL; struct lxc_limit *limelem = NULL; diff --git a/src/lxc/confile_legacy.c b/src/lxc/confile_legacy.c index 93df47376..209ae71f3 100644 --- a/src/lxc/confile_legacy.c +++ b/src/lxc/confile_legacy.c @@ -1081,7 +1081,7 @@ extern int set_config_limit(const char *key, const char *value, { struct lxc_list *iter; struct rlimit limit; - unsigned long limit_value; + rlim_t limit_value; struct lxc_list *limlist = NULL; struct lxc_limit *limelem = NULL; diff --git a/src/lxc/confile_utils.c b/src/lxc/confile_utils.c index e49178809..59d592d74 100644 --- a/src/lxc/confile_utils.c +++ b/src/lxc/confile_utils.c @@ -672,7 +672,7 @@ int lxc_get_conf_int(struct lxc_conf *c, char *retv, int inlen, int v) return snprintf(retv, inlen, "%d", v); } -bool parse_limit_value(const char **value, unsigned long *res) +bool parse_limit_value(const char **value, rlim_t *res) { char *endptr = NULL; @@ -683,7 +683,7 @@ bool parse_limit_value(const char **value, unsigned long *res) } errno = 0; - *res = strtoul(*value, &endptr, 10); + *res = strtoull(*value, &endptr, 10); if (errno || !endptr) return false; *value = endptr; diff --git a/src/lxc/confile_utils.h b/src/lxc/confile_utils.h index 2f1079a2c..585b4b52f 100644 --- a/src/lxc/confile_utils.h +++ b/src/lxc/confile_utils.h @@ -84,5 +84,5 @@ extern void update_hwaddr(const char *line); extern bool new_hwaddr(char *hwaddr); extern int lxc_get_conf_str(char *retv, int inlen, const char *value); extern int lxc_get_conf_int(struct lxc_conf *c, char *retv, int inlen, int v); -extern bool parse_limit_value(const char **value, unsigned long *res); +extern bool parse_limit_value(const char **value, rlim_t *res); #endif /* __LXC_CONFILE_UTILS_H */ -- 2.47.2