[PATCH v3 01/11] perf jevents metric: Correct Function equality

Ian Rogers posted 11 patches 2 years, 7 months ago
There is a newer version of this series
[PATCH v3 01/11] perf jevents metric: Correct Function equality
Posted by Ian Rogers 2 years, 7 months ago
rhs may not be defined, say for source_count, so add a guard.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/pmu-events/metric.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py
index 4797ed4fd817..2f2fd220e843 100644
--- a/tools/perf/pmu-events/metric.py
+++ b/tools/perf/pmu-events/metric.py
@@ -261,8 +261,10 @@ class Function(Expression):
 
   def Equals(self, other: Expression) -> bool:
     if isinstance(other, Function):
-      return self.fn == other.fn and self.lhs.Equals(
-          other.lhs) and self.rhs.Equals(other.rhs)
+      result = self.fn == other.fn and self.lhs.Equals(other.lhs)
+      if self.rhs:
+        result = result and self.rhs.Equals(other.rhs)
+      return result
     return False
 
 
-- 
2.39.0.246.g2a6d74b583-goog
Re: [PATCH v3 01/11] perf jevents metric: Correct Function equality
Posted by kajoljain 2 years, 7 months ago

On 1/24/23 12:03, Ian Rogers wrote:
> rhs may not be defined, say for source_count, so add a guard.
> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  tools/perf/pmu-events/metric.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py
> index 4797ed4fd817..2f2fd220e843 100644
> --- a/tools/perf/pmu-events/metric.py
> +++ b/tools/perf/pmu-events/metric.py
> @@ -261,8 +261,10 @@ class Function(Expression):
>  
>    def Equals(self, other: Expression) -> bool:
>      if isinstance(other, Function):
> -      return self.fn == other.fn and self.lhs.Equals(
> -          other.lhs) and self.rhs.Equals(other.rhs)
> +      result = self.fn == other.fn and self.lhs.Equals(other.lhs)
> +      if self.rhs:
> +        result = result and self.rhs.Equals(other.rhs)
> +      return result
>      return False
>  
>  

Patch looks good to me.

Reviewed-by: Kajol Jain<kjain@linux.ibm.com>

Thanks,
Kajol Jain