[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220715063653.3203761-2-irogers@google.com>
Date: Thu, 14 Jul 2022 23:36:39 -0700
From: Ian Rogers <irogers@...gle.com>
To: John Garry <john.garry@...wei.com>, Will Deacon <will@...nel.org>,
James Clark <james.clark@....com>,
Mike Leach <mike.leach@...aro.org>,
Leo Yan <leo.yan@...aro.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
Andi Kleen <ak@...ux.intel.com>,
Zhengjun Xing <zhengjun.xing@...ux.intel.com>,
Ravi Bangoria <ravi.bangoria@....com>,
Kan Liang <kan.liang@...ux.intel.com>,
Adrian Hunter <adrian.hunter@...el.com>,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-perf-users@...r.kernel.org
Cc: Stephane Eranian <eranian@...gle.com>,
Ian Rogers <irogers@...gle.com>
Subject: [PATCH v1 01/15] perf jevents: Simplify generation of C-string
Previous implementation wanted variable order and '(null)' string output
to match the C implementation. The '(null)' string output was a
quirk/bug and so there is no need to carry it forward.
Signed-off-by: Ian Rogers <irogers@...gle.com>
---
tools/perf/pmu-events/jevents.py | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
index 83e0dcbeac9a..4a170f23bd67 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -204,7 +204,7 @@ class JsonEvent:
"""Representation of the event as a C struct initializer."""
def attr_string(attr: str, value: str) -> str:
- return '\t.%s = \"%s\",\n' % (attr, value)
+ return f'\t.{attr} = \"{value}\",\n'
def str_if_present(self, attr: str) -> str:
if not getattr(self, attr):
@@ -212,17 +212,11 @@ class JsonEvent:
return attr_string(attr, getattr(self, attr))
s = '{\n'
- for attr in ['name', 'event']:
- s += str_if_present(self, attr)
- if self.desc is not None:
- s += attr_string('desc', self.desc)
- else:
- s += attr_string('desc', '(null)')
- s += str_if_present(self, 'compat')
s += f'\t.topic = "{topic_local}",\n'
for attr in [
- 'long_desc', 'pmu', 'unit', 'perpkg', 'aggr_mode', 'metric_expr',
- 'metric_name', 'metric_group', 'deprecated', 'metric_constraint'
+ 'aggr_mode', 'compat', 'deprecated', 'desc', 'event', 'long_desc',
+ 'metric_constraint', 'metric_expr', 'metric_group', 'metric_name',
+ 'name', 'perpkg', 'pmu', 'unit'
]:
s += str_if_present(self, attr)
s += '},\n'
--
2.37.0.170.g444d1eabd0-goog
Powered by blists - more mailing lists