Skip to content

Commit

Permalink
Revert "lxc-ls: Restore old [filter] behaviour"
Browse files Browse the repository at this point in the history
This reverts commit e4434e0.
  • Loading branch information
stgraber committed Jan 28, 2016
1 parent e4434e0 commit adbc2d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lxc/arguments.h
Expand Up @@ -123,7 +123,7 @@ struct lxc_arguments {
/* lxc-ls */
char *ls_fancy_format;
char *ls_groups;
char *ls_filter;
char *ls_regex;
unsigned int ls_nesting; /* maximum allowed nesting level */
bool ls_active;
bool ls_fancy;
Expand Down
14 changes: 6 additions & 8 deletions src/lxc/lxc_ls.c
Expand Up @@ -49,7 +49,6 @@ lxc_log_define(lxc_ls, lxc);
#define LS_ACTIVE 3
#define LS_RUNNING 4
#define LS_NESTING 5
#define LS_FILTER 6

/* Store container info. */
struct ls {
Expand Down Expand Up @@ -163,7 +162,7 @@ static const struct option my_longopts[] = {
{"stopped", no_argument, 0, LS_STOPPED},
{"nesting", optional_argument, 0, LS_NESTING},
{"groups", required_argument, 0, 'g'},
{"filter", required_argument, 0, LS_FILTER},
{"regex", required_argument, 0, 'r'},
LXC_COMMON_OPTIONS
};

Expand Down Expand Up @@ -356,10 +355,9 @@ static int ls_get(struct ls **m, size_t *size, const struct lxc_arguments *args,
char *name = containers[i];

/* Filter container names by regex the user gave us. */
if (args->ls_filter || args->argc == 1) {
if (args->ls_regex) {
regex_t preg;
tmp = args->ls_filter ? args->ls_filter : args->argv[0];
check = regcomp(&preg, tmp, REG_NOSUB | REG_EXTENDED);
check = regcomp(&preg, args->ls_regex, REG_NOSUB | REG_EXTENDED);
if (check == REG_ESPACE) /* we're out of memory */
goto out;
else if (check != 0)
Expand Down Expand Up @@ -924,8 +922,8 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
case 'g':
args->groups = arg;
break;
case LS_FILTER:
args->ls_filter = arg;
case 'r':
args->ls_regex = arg;
break;
case 'F':
args->ls_fancy_format = arg;
Expand Down Expand Up @@ -987,7 +985,7 @@ static int ls_remove_lock(const char *path, const char *name,
}

int check = snprintf(*lockpath, *len_lockpath, "%s/lxc/lock/%s/%s", RUNTIME_PATH, path, name);
if (check < 0 || (size_t)check >= *len_lockpath)
if (check < 0 || check >= *len_lockpath)
return -1;

lxc_rmdir_onedev(*lockpath, NULL);
Expand Down

0 comments on commit adbc2d3

Please sign in to comment.