aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/parse-events.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2012-12-08 09:18:41 -0500
committerIngo Molnar <mingo@kernel.org>2012-12-08 09:18:41 -0500
commitadc1ef1e37358d3c17d1a74a58b2e104fc0bda15 (patch)
tree6f43107a76ed87f2b817594d2d62246ab82cfba6 /tools/perf/util/parse-events.c
parent84e53ff77cb1e005f49966cd6789109d84acc9e2 (diff)
parent07ac002f2fcc74c5be47b656d9201d5de84dc53d (diff)
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: - UAPI fixes, from David Howels - Separate perf tests into multiple objects, one per test, from Jiri Olsa. - Fixes to /proc/pid/maps parsing, preparatory to supporting data maps, from Namhyung Kim - Fix compile error for non-NEWT builds, from Namhyung Kim - Implement ui_progress for GTK, from Namhyung Kim Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r--tools/perf/util/parse-events.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index c0b785b50849..020323af3364 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -722,6 +722,27 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
722 return 0; 722 return 0;
723} 723}
724 724
725/*
726 * Basic modifier sanity check to validate it contains only one
727 * instance of any modifier (apart from 'p') present.
728 */
729static int check_modifier(char *str)
730{
731 char *p = str;
732
733 /* The sizeof includes 0 byte as well. */
734 if (strlen(str) > (sizeof("ukhGHppp") - 1))
735 return -1;
736
737 while (*p) {
738 if (*p != 'p' && strchr(p + 1, *p))
739 return -1;
740 p++;
741 }
742
743 return 0;
744}
745
725int parse_events__modifier_event(struct list_head *list, char *str, bool add) 746int parse_events__modifier_event(struct list_head *list, char *str, bool add)
726{ 747{
727 struct perf_evsel *evsel; 748 struct perf_evsel *evsel;
@@ -730,6 +751,9 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add)
730 if (str == NULL) 751 if (str == NULL)
731 return 0; 752 return 0;
732 753
754 if (check_modifier(str))
755 return -EINVAL;
756
733 if (!add && get_event_modifier(&mod, str, NULL)) 757 if (!add && get_event_modifier(&mod, str, NULL))
734 return -EINVAL; 758 return -EINVAL;
735 759