From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755704AbdCGPSp (ORCPT ); Tue, 7 Mar 2017 10:18:45 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34626 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755611AbdCGPS1 (ORCPT ); Tue, 7 Mar 2017 10:18:27 -0500 From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , kernel-team@lge.com Subject: [PATCH 10/23] perf inject: Add -q/--quiet option Date: Wed, 8 Mar 2017 00:08:38 +0900 Message-Id: <20170307150851.22304-11-namhyung@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170307150851.22304-1-namhyung@kernel.org> References: <20170307150851.22304-1-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Namhyung Kim --- 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