projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Force to specify the type with add-context
[lttng-tools.git]
/
lttng
/
commands
/
add_context.c
diff --git
a/lttng/commands/add_context.c
b/lttng/commands/add_context.c
index f9094adc0af5c73ca8ab55ba4cd4fbd940208a07..1e6a807effb7393a30091bfb68e9a69c1d0cdeef 100644
(file)
--- a/
lttng/commands/add_context.c
+++ b/
lttng/commands/add_context.c
@@
-36,7
+36,6
@@
static char *opt_session_name;
static int *opt_kernel;
static int opt_pid_all;
static int opt_userspace;
static int *opt_kernel;
static int opt_pid_all;
static int opt_userspace;
-static int opt_ctx_type;
static int opt_perf_type;
static int opt_perf_id;
static pid_t opt_pid;
static int opt_perf_type;
static int opt_perf_id;
static pid_t opt_pid;
@@
-121,7
+120,7
@@
static void usage(FILE *ofp)
*
* Add context to channel or event.
*/
*
* Add context to channel or event.
*/
-static int add_context(
void
)
+static int add_context(
int type
)
{
int ret = CMD_SUCCESS;
struct lttng_kernel_context context;
{
int ret = CMD_SUCCESS;
struct lttng_kernel_context context;
@@
-131,8
+130,8
@@
static int add_context(void)
goto error;
}
goto error;
}
- context.ctx =
opt_ctx_
type;
- if (
opt_ctx_
type == LTTNG_KERNEL_CONTEXT_PERF_COUNTER) {
+ context.ctx = type;
+ if (type == LTTNG_KERNEL_CONTEXT_PERF_COUNTER) {
context.u.perf_counter.type = opt_perf_type;
context.u.perf_counter.config = opt_perf_id;
strncpy(context.u.perf_counter.name, opt_perf_name,
context.u.perf_counter.type = opt_perf_type;
context.u.perf_counter.config = opt_perf_id;
strncpy(context.u.perf_counter.name, opt_perf_name,
@@
-140,7
+139,7
@@
static int add_context(void)
}
if (opt_kernel) {
}
if (opt_kernel) {
- DBG("Adding kernel context
\n
");
+ DBG("Adding kernel context");
ret = lttng_kernel_add_context(&context, opt_event_name, opt_channel_name);
if (ret < 0) {
goto error;
ret = lttng_kernel_add_context(&context, opt_event_name, opt_channel_name);
if (ret < 0) {
goto error;
@@
-172,10
+171,15
@@
error:
*/
int cmd_add_context(int argc, const char **argv)
{
*/
int cmd_add_context(int argc, const char **argv)
{
- int opt, ret;
+ int opt, ret
= CMD_SUCCESS
;
char *tmp;
static poptContext pc;
char *tmp;
static poptContext pc;
+ if (argc < 2) {
+ usage(stderr);
+ goto end;
+ }
+
pc = poptGetContext(NULL, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
pc = poptGetContext(NULL, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
@@
-191,9
+195,15
@@
int cmd_add_context(int argc, const char **argv)
if (tmp == NULL) {
usage(stderr);
ret = CMD_ERROR;
if (tmp == NULL) {
usage(stderr);
ret = CMD_ERROR;
+ free(tmp);
goto end;
}
goto end;
}
- opt_ctx_type = atoi(tmp);
+ ret = add_context(atoi(tmp));
+ if (ret < 0) {
+ free(tmp);
+ goto end;
+ }
+ free(tmp);
break;
default:
usage(stderr);
break;
default:
usage(stderr);
@@
-202,8
+212,6
@@
int cmd_add_context(int argc, const char **argv)
}
}
}
}
- ret = add_context();
-
end:
return ret;
}
end:
return ret;
}
This page took
0.025872 seconds
and
4
git commands to generate.