Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1594328

[PATCH 10/23] perf inject: Add -q/--quiet option

From Namhyung Kim <namhyung@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 10/23] perf inject: Add -q/--quiet option
Date 2017-03-07 16:20 +0100
Message-ID <tip46-X4-11@gated-at.bofh.it> (permalink)
References <tip46-X4-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The -q/--quiet option is to suppress any message.  Sometimes users just
want to run the command and it can be used for that case.

Suggested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Documentation/perf-inject.txt |  3 +++
 tools/perf/builtin-inject.c              | 10 ++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Documentation/perf-inject.txt b/tools/perf/Documentation/perf-inject.txt
index 87b2588d1cbd..c69fe37c38cc 100644
--- a/tools/perf/Documentation/perf-inject.txt
+++ b/tools/perf/Documentation/perf-inject.txt
@@ -29,6 +29,9 @@ OPTIONS
 -v::
 --verbose::
 	Be more verbose.
+-q::
+--quiet::
+	Do not show any message.
 -i::
 --input=::
 	Input file name. (default: stdin)
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index b9bc7e39833a..a2d94be1b27d 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -484,8 +484,10 @@ static int perf_inject__sched_switch(struct perf_tool *tool,
 
 	ent = malloc(event->header.size + sizeof(struct event_entry));
 	if (ent == NULL) {
-		color_fprintf(stderr, PERF_COLOR_RED,
+		if (!quiet) {
+			color_fprintf(stderr, PERF_COLOR_RED,
 			     "Not enough memory to process sched switch event!");
+		}
 		return -1;
 	}
 
@@ -780,6 +782,7 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
 #endif
 		OPT_INCR('v', "verbose", &verbose,
 			 "be more verbose (show build ids, etc)"),
+		OPT_BOOLEAN('q', "quiet", &quiet, "do not show any message"),
 		OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, "file",
 			   "kallsyms pathname"),
 		OPT_BOOLEAN('f', "force", &file.force, "don't complain, do it"),
@@ -805,13 +808,16 @@ int cmd_inject(int argc, const char **argv, const char *prefix __maybe_unused)
 	if (argc)
 		usage_with_options(inject_usage, options);
 
+	if (quiet)
+		perf_quiet_option();
+
 	if (inject.strip && !inject.itrace_synth_opts.set) {
 		pr_err("--strip option requires --itrace option\n");
 		return -1;
 	}
 
 	if (perf_data_file__open(&inject.output)) {
-		perror("failed to create output file");
+		pr_err("failed to create output file: %s\n", strerror(errno));
 		return -1;
 	}
 
-- 
2.11.0

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 10/23] perf inject: Add -q/--quiet option Namhyung Kim <namhyung@kernel.org> - 2017-03-07 16:20 +0100

csiph-web