Re: [PATCH 24/33] perf, tools: Move parse_events error printing to parse_events_options

2012-10-27 Thread Jiri Olsa
On Fri, Oct 26, 2012 at 01:30:06PM -0700, Andi Kleen wrote:
> From: Andi Kleen 
> 
> The callers of parse_events usually have their own error handling.
> Move the fprintf for a bad event to parse_events_options, which
> is the only one who should need it.
> 
> Signed-off-by: Andi Kleen 
> ---
>  tools/perf/util/parse-events.c |   10 +++---
>  1 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 75c7b0f..409da3e 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -827,8 +827,6 @@ int parse_events(struct perf_evlist *evlist, const char 
> *str,
>* Both call perf_evlist__delete in case of error, so we dont
>* need to bother.
>*/
> - fprintf(stderr, "invalid or unsupported event: '%s'\n", str);
> - fprintf(stderr, "Run 'perf list' for a list of valid events\n");
>   return ret;
>  }
>  
> @@ -836,7 +834,13 @@ int parse_events_option(const struct option *opt, const 
> char *str,
>   int unset __maybe_unused)
>  {
>   struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
> - return parse_events(evlist, str, unset);
> + int ret = parse_events(evlist, str, unset);
> +
> + if (ret) {
> + fprintf(stderr, "invalid or unsupported event: '%s'\n", str);
> + fprintf(stderr, "Run 'perf list' for a list of valid events\n");
> + }
> + return ret;
>  }
>  
>  int parse_filter(const struct option *opt, const char *str,
> -- 
> 1.7.7.6
> 

Acked-by: Jiri Olsa 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 24/33] perf, tools: Move parse_events error printing to parse_events_options

2012-10-27 Thread Jiri Olsa
On Fri, Oct 26, 2012 at 01:30:06PM -0700, Andi Kleen wrote:
 From: Andi Kleen a...@linux.intel.com
 
 The callers of parse_events usually have their own error handling.
 Move the fprintf for a bad event to parse_events_options, which
 is the only one who should need it.
 
 Signed-off-by: Andi Kleen a...@linux.intel.com
 ---
  tools/perf/util/parse-events.c |   10 +++---
  1 files changed, 7 insertions(+), 3 deletions(-)
 
 diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
 index 75c7b0f..409da3e 100644
 --- a/tools/perf/util/parse-events.c
 +++ b/tools/perf/util/parse-events.c
 @@ -827,8 +827,6 @@ int parse_events(struct perf_evlist *evlist, const char 
 *str,
* Both call perf_evlist__delete in case of error, so we dont
* need to bother.
*/
 - fprintf(stderr, invalid or unsupported event: '%s'\n, str);
 - fprintf(stderr, Run 'perf list' for a list of valid events\n);
   return ret;
  }
  
 @@ -836,7 +834,13 @@ int parse_events_option(const struct option *opt, const 
 char *str,
   int unset __maybe_unused)
  {
   struct perf_evlist *evlist = *(struct perf_evlist **)opt-value;
 - return parse_events(evlist, str, unset);
 + int ret = parse_events(evlist, str, unset);
 +
 + if (ret) {
 + fprintf(stderr, invalid or unsupported event: '%s'\n, str);
 + fprintf(stderr, Run 'perf list' for a list of valid events\n);
 + }
 + return ret;
  }
  
  int parse_filter(const struct option *opt, const char *str,
 -- 
 1.7.7.6
 

Acked-by: Jiri Olsa jo...@redhat.com
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 24/33] perf, tools: Move parse_events error printing to parse_events_options

2012-10-26 Thread Andi Kleen
From: Andi Kleen 

The callers of parse_events usually have their own error handling.
Move the fprintf for a bad event to parse_events_options, which
is the only one who should need it.

Signed-off-by: Andi Kleen 
---
 tools/perf/util/parse-events.c |   10 +++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 75c7b0f..409da3e 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -827,8 +827,6 @@ int parse_events(struct perf_evlist *evlist, const char 
*str,
 * Both call perf_evlist__delete in case of error, so we dont
 * need to bother.
 */
-   fprintf(stderr, "invalid or unsupported event: '%s'\n", str);
-   fprintf(stderr, "Run 'perf list' for a list of valid events\n");
return ret;
 }
 
@@ -836,7 +834,13 @@ int parse_events_option(const struct option *opt, const 
char *str,
int unset __maybe_unused)
 {
struct perf_evlist *evlist = *(struct perf_evlist **)opt->value;
-   return parse_events(evlist, str, unset);
+   int ret = parse_events(evlist, str, unset);
+
+   if (ret) {
+   fprintf(stderr, "invalid or unsupported event: '%s'\n", str);
+   fprintf(stderr, "Run 'perf list' for a list of valid events\n");
+   }
+   return ret;
 }
 
 int parse_filter(const struct option *opt, const char *str,
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 24/33] perf, tools: Move parse_events error printing to parse_events_options

2012-10-26 Thread Andi Kleen
From: Andi Kleen a...@linux.intel.com

The callers of parse_events usually have their own error handling.
Move the fprintf for a bad event to parse_events_options, which
is the only one who should need it.

Signed-off-by: Andi Kleen a...@linux.intel.com
---
 tools/perf/util/parse-events.c |   10 +++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 75c7b0f..409da3e 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -827,8 +827,6 @@ int parse_events(struct perf_evlist *evlist, const char 
*str,
 * Both call perf_evlist__delete in case of error, so we dont
 * need to bother.
 */
-   fprintf(stderr, invalid or unsupported event: '%s'\n, str);
-   fprintf(stderr, Run 'perf list' for a list of valid events\n);
return ret;
 }
 
@@ -836,7 +834,13 @@ int parse_events_option(const struct option *opt, const 
char *str,
int unset __maybe_unused)
 {
struct perf_evlist *evlist = *(struct perf_evlist **)opt-value;
-   return parse_events(evlist, str, unset);
+   int ret = parse_events(evlist, str, unset);
+
+   if (ret) {
+   fprintf(stderr, invalid or unsupported event: '%s'\n, str);
+   fprintf(stderr, Run 'perf list' for a list of valid events\n);
+   }
+   return ret;
 }
 
 int parse_filter(const struct option *opt, const char *str,
-- 
1.7.7.6

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/