Skip to content

Commit

Permalink
tools: s/MAXPATHLEN/PATH_MAX/g
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Oct 7, 2018
1 parent 339de29 commit 3a5996f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/lxc/tools/lxc_cgroup.c
Expand Up @@ -137,10 +137,10 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
} else {
char buffer[MAXPATHLEN];
char buffer[PATH_MAX];
int ret;

ret = c->get_cgroup_item(c, state_object, buffer, MAXPATHLEN);
ret = c->get_cgroup_item(c, state_object, buffer, PATH_MAX);
if (ret < 0) {
ERROR("Failed to retrieve value of '%s' for '%s:%s'",
state_object, my_args.lxcpath[0], my_args.name);
Expand Down
20 changes: 10 additions & 10 deletions src/lxc/tools/lxc_copy.c
Expand Up @@ -263,17 +263,17 @@ static struct mnts *add_mnt(struct mnts **mnts, unsigned int *num, enum mnttype

static int mk_rand_ovl_dirs(struct mnts *mnts, unsigned int num, struct lxc_arguments *arg)
{
char upperdir[MAXPATHLEN];
char workdir[MAXPATHLEN];
char upperdir[PATH_MAX];
char workdir[PATH_MAX];
unsigned int i;
int ret;
struct mnts *m = NULL;

for (i = 0, m = mnts; i < num; i++, m++) {
if (m->mnt_type == LXC_MNT_OVL) {
ret = snprintf(upperdir, MAXPATHLEN, "%s/%s/delta#XXXXXX",
ret = snprintf(upperdir, PATH_MAX, "%s/%s/delta#XXXXXX",
arg->newpath, arg->newname);
if (ret < 0 || ret >= MAXPATHLEN)
if (ret < 0 || ret >= PATH_MAX)
return -1;

if (!mkdtemp(upperdir))
Expand All @@ -285,9 +285,9 @@ static int mk_rand_ovl_dirs(struct mnts *mnts, unsigned int num, struct lxc_argu
}

if (m->mnt_type == LXC_MNT_OVL) {
ret = snprintf(workdir, MAXPATHLEN, "%s/%s/work#XXXXXX",
ret = snprintf(workdir, PATH_MAX, "%s/%s/work#XXXXXX",
arg->newpath, arg->newname);
if (ret < 0 || ret >= MAXPATHLEN)
if (ret < 0 || ret >= PATH_MAX)
return -1;

if (!mkdtemp(workdir))
Expand Down Expand Up @@ -381,7 +381,7 @@ static int do_clone_ephemeral(struct lxc_container *c,
struct lxc_arguments *arg, char **args, int flags)
{
char *premount;
char randname[MAXPATHLEN];
char randname[PATH_MAX];
unsigned int i;
int ret = 0;
bool bret = true, started = false;
Expand All @@ -391,8 +391,8 @@ static int do_clone_ephemeral(struct lxc_container *c,
attach_options.env_policy = LXC_ATTACH_CLEAR_ENV;

if (!arg->newname) {
ret = snprintf(randname, MAXPATHLEN, "%s/%s_XXXXXX", arg->newpath, arg->name);
if (ret < 0 || ret >= MAXPATHLEN)
ret = snprintf(randname, PATH_MAX, "%s/%s_XXXXXX", arg->newpath, arg->name);
if (ret < 0 || ret >= PATH_MAX)
return -1;

if (!mkdtemp(randname))
Expand Down Expand Up @@ -481,7 +481,7 @@ static int do_clone_ephemeral(struct lxc_container *c,
if (started)
clone->shutdown(clone, -1);

ret = clone->get_config_item(clone, "lxc.ephemeral", tmp_buf, MAXPATHLEN);
ret = clone->get_config_item(clone, "lxc.ephemeral", tmp_buf, PATH_MAX);
if (ret > 0 && strcmp(tmp_buf, "0"))
clone->destroy(clone);

Expand Down
20 changes: 10 additions & 10 deletions src/lxc/tools/lxc_destroy.c
Expand Up @@ -84,20 +84,20 @@ static bool do_destroy(struct lxc_container *c)
{
int ret;
bool bret = true;
char path[MAXPATHLEN];
char path[PATH_MAX];

/* First check whether the container has dependent clones or snapshots. */
ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", c->config_path, c->name);
if (ret < 0 || ret >= MAXPATHLEN)
ret = snprintf(path, PATH_MAX, "%s/%s/lxc_snapshots", c->config_path, c->name);
if (ret < 0 || ret >= PATH_MAX)
return false;

if (file_exists(path)) {
ERROR("Destroying %s failed: %s has clones", c->name, c->name);
return false;
}

ret = snprintf(path, MAXPATHLEN, "%s/%s/snaps", c->config_path, c->name);
if (ret < 0 || ret >= MAXPATHLEN)
ret = snprintf(path, PATH_MAX, "%s/%s/snaps", c->config_path, c->name);
if (ret < 0 || ret >= PATH_MAX)
return false;

if (rmdir(path) < 0 && errno != ENOENT) {
Expand Down Expand Up @@ -138,7 +138,7 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
struct lxc_container *c1;
struct stat fbuf;
bool bret = false;
char path[MAXPATHLEN];
char path[PATH_MAX];
char *buf = NULL;
char *lxcpath = NULL;
char *lxcname = NULL;
Expand All @@ -147,8 +147,8 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
ssize_t bytes;

/* Destroy clones. */
ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", c->config_path, c->name);
if (ret < 0 || ret >= MAXPATHLEN)
ret = snprintf(path, PATH_MAX, "%s/%s/lxc_snapshots", c->config_path, c->name);
if (ret < 0 || ret >= PATH_MAX)
return false;

fd = open(path, O_RDONLY | O_CLOEXEC);
Expand Down Expand Up @@ -195,8 +195,8 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
}

/* Destroy snapshots located in the containers snap/ folder. */
ret = snprintf(path, MAXPATHLEN, "%s/%s/snaps", c->config_path, c->name);
if (ret < 0 || ret >= MAXPATHLEN)
ret = snprintf(path, PATH_MAX, "%s/%s/snaps", c->config_path, c->name);
if (ret < 0 || ret >= PATH_MAX)
return false;

if (rmdir(path) < 0 && errno != ENOENT)
Expand Down
4 changes: 2 additions & 2 deletions src/lxc/tools/lxc_execute.c
Expand Up @@ -129,11 +129,11 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
static bool set_argv(struct lxc_container *c, struct lxc_arguments *args)
{
int ret;
char buf[MAXPATHLEN];
char buf[PATH_MAX];
char **components, **p;

buf[0] = '\0';
ret = c->get_config_item(c, "lxc.execute.cmd", buf, MAXPATHLEN);
ret = c->get_config_item(c, "lxc.execute.cmd", buf, PATH_MAX);
if (ret < 0)
return false;

Expand Down
2 changes: 1 addition & 1 deletion src/lxc/tools/lxc_unshare.c
Expand Up @@ -182,7 +182,7 @@ static int get_namespace_flags(char *namespaces)

static bool lookup_user(const char *optarg, uid_t *uid)
{
char name[MAXPATHLEN];
char name[PATH_MAX];
struct passwd pwent;
struct passwd *pwentp = NULL;
char *buf;
Expand Down

0 comments on commit 3a5996f

Please sign in to comment.