X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbin%2Flttng%2Fcommands%2Ftrack-untrack.c;h=ea05574514ab698e06c65b46e4f7dce84e8c13f5;hb=3ecec76a3cd1eb6b301d03895ab425976ba28dee;hp=b3139c6931998003757d797991258881b79d02f9;hpb=b93a4a13a2724a73069e1d661df5df83c629bb36;p=lttng-tools.git diff --git a/src/bin/lttng/commands/track-untrack.c b/src/bin/lttng/commands/track-untrack.c index b3139c693..ea0557451 100644 --- a/src/bin/lttng/commands/track-untrack.c +++ b/src/bin/lttng/commands/track-untrack.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -208,14 +209,14 @@ enum cmd_error_code track_untrack_pid(enum cmd_type cmd_type, const char *cmd_st int nr_pids; struct lttng_domain dom; struct lttng_handle *handle = NULL; - int (*lib_func)(struct lttng_handle *handle, int pid); + int (*cmd_func)(struct lttng_handle *handle, int pid); switch (cmd_type) { case CMD_TRACK: - lib_func = lttng_track_pid; + cmd_func = lttng_track_pid; break; case CMD_UNTRACK: - lib_func = lttng_untrack_pid; + cmd_func = lttng_untrack_pid; break; default: ERR("Unknown command"); @@ -229,9 +230,8 @@ enum cmd_error_code track_untrack_pid(enum cmd_type cmd_type, const char *cmd_st } else if (opt_userspace) { dom.type = LTTNG_DOMAIN_UST; } else { - print_missing_domain(); - ret = CMD_ERROR; - goto end; + /* Checked by the caller. */ + assert(0); } ret = parse_pid_string(pid_string, all, &pid_list, &nr_pids); @@ -259,7 +259,7 @@ enum cmd_error_code track_untrack_pid(enum cmd_type cmd_type, const char *cmd_st for (i = 0; i < nr_pids; i++) { DBG("%s PID %d", cmd_str, pid_list[i]); - ret = lib_func(handle, pid_list[i]); + ret = cmd_func(handle, pid_list[i]); if (ret) { switch (-ret) { case LTTNG_ERR_PID_TRACKED: @@ -381,10 +381,9 @@ int cmd_track_untrack(enum cmd_type cmd_type, const char *cmd_str, } } - if (!(opt_userspace ^ opt_kernel)) { - ERR("Exactly one of -u or -k needs to be specified."); - usage(stderr, cmd_str); - command_ret = CMD_ERROR; + ret = print_missing_or_multiple_domains(opt_kernel + opt_userspace); + if (ret) { + ret = CMD_ERROR; goto end; }