Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
confile: make parse_limit_value() static
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Apr 10, 2019
1 parent 6fccdc3 commit bb112e5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
20 changes: 20 additions & 0 deletions src/lxc/confile.c
Expand Up @@ -1315,6 +1315,26 @@ static int set_config_cgroup_dir(const char *key, const char *value,
return set_config_string_item(&lxc_conf->cgroup_meta.dir, value);
}

static bool parse_limit_value(const char **value, rlim_t *res)
{
char *endptr = NULL;

if (strncmp(*value, "unlimited", STRLITERALLEN("unlimited")) == 0) {
*res = RLIM_INFINITY;
*value += STRLITERALLEN("unlimited");
return true;
}

errno = 0;
*res = strtoull(*value, &endptr, 10);
if (errno || !endptr)
return false;

*value = endptr;

return true;
}

static int set_config_prlimit(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
{
Expand Down
21 changes: 1 addition & 20 deletions src/lxc/confile_utils.c
Expand Up @@ -654,6 +654,7 @@ int lxc_get_conf_int(struct lxc_conf *c, char *retv, int inlen, int v)

return fulllen;
}

int lxc_get_conf_size_t(struct lxc_conf *c, char *retv, int inlen, size_t v)
{
int len;
Expand Down Expand Up @@ -684,26 +685,6 @@ int lxc_get_conf_uint64(struct lxc_conf *c, char *retv, int inlen, uint64_t v)
return fulllen;
}

bool parse_limit_value(const char **value, rlim_t *res)
{
char *endptr = NULL;

if (strncmp(*value, "unlimited", STRLITERALLEN("unlimited")) == 0) {
*res = RLIM_INFINITY;
*value += STRLITERALLEN("unlimited");
return true;
}

errno = 0;
*res = strtoull(*value, &endptr, 10);
if (errno || !endptr)
return false;

*value = endptr;

return true;
}

static int lxc_container_name_to_pid(const char *lxcname_or_pid,
const char *lxcpath)
{
Expand Down
1 change: 0 additions & 1 deletion src/lxc/confile_utils.h
Expand Up @@ -72,7 +72,6 @@ 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 int lxc_get_conf_size_t(struct lxc_conf *c, char *retv, int inlen, size_t v);
extern int lxc_get_conf_uint64(struct lxc_conf *c, char *retv, int inlen, uint64_t v);
extern bool parse_limit_value(const char **value, rlim_t *res);
extern int lxc_inherit_namespace(const char *lxcname_or_pid,
const char *lxcpath, const char *namespace);
extern int sig_parse(const char *signame);
Expand Down

0 comments on commit bb112e5

Please sign in to comment.