Fix incorrect POPT_ARG_STRING usage
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 14 Nov 2011 14:40:48 +0000 (09:40 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 14 Nov 2011 14:40:48 +0000 (09:40 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng/commands/add_context.c
lttng/commands/calibrate.c
lttng/commands/disable_channels.c
lttng/commands/disable_events.c
lttng/commands/enable_channels.c
lttng/commands/list.c

index dd13d223be9e5aac96aab78cc1ba9a5889803995..02220415d88d5c17e186dfef123be903115b6c93 100644 (file)
@@ -42,6 +42,7 @@ static int opt_pid_all;
 static int opt_userspace;
 static char *opt_cmd_name;
 static pid_t opt_pid;
+static char *opt_type;
 
 enum {
        OPT_HELP = 1,
@@ -143,7 +144,7 @@ static struct poptOption long_options[] = {
        {"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}
 };
 
@@ -416,7 +417,6 @@ error:
 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;
@@ -436,32 +436,23 @@ int cmd_add_context(int argc, const char **argv)
                        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;
index 6979ef6eaa0c765852b938abd779d2c1edbe2397..1219685e7515ab8ca5541c3c8f9222a53c6e602d 100644 (file)
@@ -56,7 +56,7 @@ static struct poptOption long_options[] = {
        /* 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},
@@ -201,7 +201,6 @@ int cmd_calibrate(int argc, const char **argv)
                        break;
                case OPT_USERSPACE:
                        opt_userspace = 1;
-                       opt_cmd_name = poptGetOptArg(pc);
                        break;
                default:
                        usage(stderr);
index 262165eb3f0162f09580b83f9913f621df10c10f..a45f3ef092b8aad46cdd9a93d144b7985e1841c8 100644 (file)
@@ -49,7 +49,7 @@ static struct poptOption long_options[] = {
        {"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}
@@ -148,7 +148,6 @@ int cmd_disable_channels(int argc, const char **argv)
                        goto end;
                case OPT_USERSPACE:
                        opt_userspace = 1;
-                       opt_cmd_name = poptGetOptArg(pc);
                        break;
                default:
                        usage(stderr);
index 09b61cbe25da6f55bb4bed2751bc9befec57bad3..13ebd6c3acff763b235bfc4748fab0404716c81c 100644 (file)
@@ -53,7 +53,7 @@ static struct poptOption long_options[] = {
        {"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}
@@ -182,7 +182,6 @@ int cmd_disable_events(int argc, const char **argv)
                        goto end;
                case OPT_USERSPACE:
                        opt_userspace = 1;
-                       opt_cmd_name = poptGetOptArg(pc);
                        break;
                default:
                        usage(stderr);
index aac5fa4979c9d274b62f72ee61bcdd67c311dd9b..48e83df28a53039ad90f09d34f65ce74d03c3961 100644 (file)
@@ -58,7 +58,7 @@ static struct poptOption long_options[] = {
        {"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},
@@ -235,7 +235,6 @@ int cmd_enable_channels(int argc, const char **argv)
                        break;
                case OPT_USERSPACE:
                        opt_userspace = 1;
-                       opt_cmd_name = poptGetOptArg(pc);
                        break;
                default:
                        usage(stderr);
index e2d5b6643d5df24f15d5a2bb658ae6460604c22e..fcfaa3f23513d0970c0f609f521f5f25ac2e20dd 100644 (file)
@@ -48,7 +48,7 @@ static struct poptOption long_options[] = {
        /* 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},
@@ -481,7 +481,6 @@ int cmd_list(int argc, const char **argv)
                        goto end;
                case OPT_USERSPACE:
                        opt_userspace = 1;
-                       opt_cmd_name = poptGetOptArg(pc);
                        break;
                default:
                        usage(stderr);
This page took 0.030213 seconds and 4 git commands to generate.