Skip to contentSkip to conversation

perf tools: Fix NULL vs IS_ERR_OR_NULL() checking

PATCH Applied Miaoqian Lin 2 participants 2 messages Dec 11, 2021 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tools: Fix NULL vs IS_ERR_OR_NULL() checking

The function trace_event__tp_format_id may return ERR_PTR(-ENOMEM). Use IS_ERR_OR_NULL to check tp_format.

---
 tools/perf/util/python.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/python.c +1 -1
index 563a9ba8954f..7f782a31bda3 100644
@@ -461,7 +461,7 @@ get_tracepoint_field(struct pyrf_event *pevent, PyObject *attr_name)
 		struct tep_event *tp_format;
 
 		tp_format = trace_event__tp_format_id(evsel->core.attr.config);
-		if (!tp_format)
+		if (IS_ERR_OR_NULL(tp_format))
 			return NULL;
 
 		evsel->tp_format = tp_format;
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw

Em Sat, Dec 11, 2021 at 05:38:53AM +0000, Miaoqian Lin escreveu:

Quoted 2 lines

The function trace_event__tp_format_id may return ERR_PTR(-ENOMEM). Use IS_ERR_OR_NULL to check tp_format.

Thanks, applied.

- Arnaldo

Quoted 20 lines
---
 tools/perf/util/python.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/python.c +1 -1
index 563a9ba8954f..7f782a31bda3 100644
@@ -461,7 +461,7 @@ get_tracepoint_field(struct pyrf_event *pevent, PyObject *attr_name)
 		struct tep_event *tp_format;
 
 		tp_format = trace_event__tp_format_id(evsel->core.attr.config);
-		if (!tp_format)
+		if (IS_ERR_OR_NULL(tp_format))
 			return NULL;
 
 		evsel->tp_format = tp_format;
Signature · 1 line
2.17.1
Signature · 1 line
- Arnaldo