static int opt_userspace;
static char *opt_cmd_name;
static pid_t opt_pid;
+static char *opt_type;
enum {
OPT_HELP = 1,
{"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, 0, OPT_USERSPACE, 0, 0},
{"all", 0, POPT_ARG_VAL, &opt_pid_all, 1, 0, 0},
{"pid", 'p', POPT_ARG_INT, &opt_pid, 0, 0, 0},
- {"type", 't', POPT_ARG_STRING, 0, OPT_TYPE, 0, 0},
+ {"type", 't', POPT_ARG_STRING, &opt_type, OPT_TYPE, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
};
int cmd_add_context(int argc, const char **argv)
{
int index, opt, ret = CMD_SUCCESS;
- char *tmp;
static poptContext pc;
struct ctx_type *type, *tmptype;
char *session_name = NULL;
ret = CMD_SUCCESS;
goto end;
case OPT_TYPE:
- /* Mandatory field */
- tmp = poptGetOptArg(pc);
- if (tmp == NULL) {
- usage(stderr);
- ret = CMD_ERROR;
- free(tmp);
- goto end;
- }
type = malloc(sizeof(struct ctx_type));
if (type == NULL) {
perror("malloc ctx_type");
ret = -1;
goto end;
}
- index = find_ctx_type_idx(tmp);
+ index = find_ctx_type_idx(opt_type);
if (index < 0) {
- ERR("Unknown context type %s", tmp);
+ ERR("Unknown context type %s", opt_type);
goto end;
}
type->opt = &ctx_opts[index];
if (type->opt->ctx_type == -1) {
- ERR("Unknown context type %s", tmp);
+ ERR("Unknown context type %s", opt_type);
} else {
cds_list_add(&type->list, &ctx_type_list.head);
}
- free(tmp);
break;
case OPT_USERSPACE:
opt_userspace = 1;
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
{"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
{"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, 0, OPT_USERSPACE, 0, 0},
+ {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_cmd_name, OPT_USERSPACE, 0, 0},
{"all", 0, POPT_ARG_VAL, &opt_pid_all, 1, 0, 0},
{"pid", 'p', POPT_ARG_INT, &opt_pid, 0, 0, 0},
{"tracepoint", 0, POPT_ARG_NONE, 0, OPT_TRACEPOINT, 0, 0},
break;
case OPT_USERSPACE:
opt_userspace = 1;
- opt_cmd_name = poptGetOptArg(pc);
break;
default:
usage(stderr);
{"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
{"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
{"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, 0, OPT_USERSPACE, 0, 0},
+ {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_cmd_name, OPT_USERSPACE, 0, 0},
{"all", 0, POPT_ARG_VAL, &opt_pid_all, 1, 0, 0},
{"pid", 'p', POPT_ARG_INT, &opt_pid, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
goto end;
case OPT_USERSPACE:
opt_userspace = 1;
- opt_cmd_name = poptGetOptArg(pc);
break;
default:
usage(stderr);
{"all-events", 'a', POPT_ARG_VAL, &opt_disable_all, 1, 0, 0},
{"channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0},
{"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, 0, OPT_USERSPACE, 0, 0},
+ {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_cmd_name, OPT_USERSPACE, 0, 0},
{"all", 0, POPT_ARG_VAL, &opt_pid_all, 1, 0, 0},
{"pid", 'p', POPT_ARG_INT, &opt_pid, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0}
goto end;
case OPT_USERSPACE:
opt_userspace = 1;
- opt_cmd_name = poptGetOptArg(pc);
break;
default:
usage(stderr);
{"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
{"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
{"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, 0, OPT_USERSPACE, 0, 0},
+ {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_cmd_name, OPT_USERSPACE, 0, 0},
{"all", 0, POPT_ARG_VAL, &opt_pid_all, 1, 0, 0},
{"pid", 'p', POPT_ARG_INT, &opt_pid, 0, 0, 0},
{"discard", 0, POPT_ARG_NONE, 0, OPT_DISCARD, 0, 0},
break;
case OPT_USERSPACE:
opt_userspace = 1;
- opt_cmd_name = poptGetOptArg(pc);
break;
default:
usage(stderr);
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
{"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
{"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
- {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, 0, OPT_USERSPACE, 0, 0},
+ {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, &opt_cmd_name, OPT_USERSPACE, 0, 0},
{"pid", 'p', POPT_ARG_INT, &opt_pid, 0, 0, 0},
{"channel", 'c', POPT_ARG_STRING, &opt_channel, 0, 0, 0},
{"domain", 'd', POPT_ARG_VAL, &opt_domain, 1, 0, 0},
goto end;
case OPT_USERSPACE:
opt_userspace = 1;
- opt_cmd_name = poptGetOptArg(pc);
break;
default:
usage(stderr);