lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1380113447-17144-18-git-send-email-jolsa@redhat.com>
Date:	Wed, 25 Sep 2013 14:50:43 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	Jiri Olsa <jolsa@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...e.hu>, Paul Mackerras <paulus@...ba.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: [PATCH 17/21] perf tools: Add event_config_optional parsing rule

Adding 'event_config_optional' parsing rule to omit
duplication code in event_legacy_symbol for /config/no config/
processing.

Signed-off-by: Jiri Olsa <jolsa@...hat.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/perf/util/parse-events.c |  3 +++
 tools/perf/util/parse-events.y | 34 ++++++++++++++++++----------------
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 1957849..37b9cb7 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1328,6 +1328,9 @@ void parse_events__free_terms(struct list_head *terms)
 {
 	struct parse_events_term *term, *h;
 
+	if (!terms)
+		return;
+
 	list_for_each_entry_safe(term, h, terms, list)
 		free(term);
 }
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 4eb67ec..1497a70 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -59,6 +59,7 @@ static inc_group_count(struct list_head *list,
 %type <str> PE_MODIFIER_BP
 %type <str> PE_EVENT_NAME
 %type <num> value_sym
+%type <head> event_config_optional
 %type <head> event_config
 %type <term> event_term
 %type <head> event_pmu
@@ -199,6 +200,17 @@ event_def: event_pmu |
 	   event_legacy_numeric sep_dc |
 	   event_legacy_raw sep_dc
 
+event_config_optional:
+'/' event_config '/'
+{
+	$$ = $2;
+}
+|
+sep_slash_dc
+{
+	$$ = NULL;
+}
+
 event_pmu:
 PE_NAME '/' event_config '/'
 {
@@ -208,6 +220,7 @@ PE_NAME '/' event_config '/'
 	ALLOC_LIST(list);
 	ABORT_ON(parse_events_add_pmu(list, &data->idx, $1, $3));
 	parse_events__free_terms($3);
+	free($3);
 	$$ = list;
 }
 
@@ -217,30 +230,19 @@ PE_VALUE_SYM_HW
 PE_VALUE_SYM_SW
 
 event_legacy_symbol:
-value_sym '/' event_config '/'
-{
-	struct parse_events_evlist *data = _data;
-	struct list_head *list;
-	int type = $1 >> 16;
-	int config = $1 & 255;
-
-	ALLOC_LIST(list);
-	ABORT_ON(parse_events_add_numeric(list, &data->idx,
-					  type, config, $3));
-	parse_events__free_terms($3);
-	$$ = list;
-}
-|
-value_sym sep_slash_dc
+value_sym event_config_optional
 {
 	struct parse_events_evlist *data = _data;
 	struct list_head *list;
+	struct list_head *terms = $2;
 	int type = $1 >> 16;
 	int config = $1 & 255;
 
 	ALLOC_LIST(list);
 	ABORT_ON(parse_events_add_numeric(list, &data->idx,
-					  type, config, NULL));
+					  type, config, terms));
+	parse_events__free_terms(terms);
+	free(terms);
 	$$ = list;
 }
 
-- 
1.7.11.7

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ