Skip to content

Commit

Permalink
tools/lxc_info: do not hide global variable
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 22, 2018
1 parent 551105f commit e69abbb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/lxc/tools/lxc_info.c
Expand Up @@ -48,7 +48,7 @@ static bool pid;
static bool stats;
static bool humanize = true;
static char **key = NULL;
static int keys = 0;
static int nr_keys = 0;
static int filter_count = 0;

static int my_parser(struct lxc_arguments *args, int c, char *arg)
Expand All @@ -57,13 +57,13 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)

switch (c) {
case 'c':
newk = realloc(key, (keys + 1) * sizeof(key[0]));
newk = realloc(key, (nr_keys + 1) * sizeof(key[0]));
if (!newk)
return -1;

key = newk;
key[keys] = arg;
keys++;
key[nr_keys] = arg;
nr_keys++;
break;
case 'i': ips = true; filter_count += 1; break;
case 's': state = true; filter_count += 1; break;
Expand Down Expand Up @@ -341,7 +341,7 @@ static int print_info(const char *name, const char *lxcpath)
return -1;
}

if (!state && !pid && !ips && !stats && keys <= 0) {
if (!state && !pid && !ips && !stats && nr_keys <= 0) {
state = pid = ips = stats = true;
print_info_msg_str("Name:", c->name);
}
Expand Down Expand Up @@ -380,7 +380,7 @@ static int print_info(const char *name, const char *lxcpath)
print_net_stats(c);
}

for(i = 0; i < keys; i++) {
for(i = 0; i < nr_keys; i++) {
int len = c->get_config_item(c, key[i], NULL, 0);

if (len > 0) {
Expand All @@ -389,15 +389,15 @@ static int print_info(const char *name, const char *lxcpath)
if (c->get_config_item(c, key[i], val, len + 1) != len) {
fprintf(stderr, "unable to read %s from configuration\n", key[i]);
} else {
if (!humanize && keys == 1)
if (!humanize && nr_keys == 1)
printf("%s\n", val);
else
printf("%s = %s\n", key[i], val);
}

free(val);
} else if (len == 0) {
if (!humanize && keys == 1)
if (!humanize && nr_keys == 1)
printf("\n");
else
printf("%s =\n", key[i]);
Expand Down

0 comments on commit e69abbb

Please sign in to comment.