[PATCH 1/2] trace-cruncher: Add error handling to PyTep_short_kprobe_print()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The return value of the libtracefs API used internally has to be
checked and an error message printed in a case of an error.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx>
---
 src/ftracepy-utils.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c
index 85f5bbc..e8411ae 100644
--- a/src/ftracepy-utils.c
+++ b/src/ftracepy-utils.c
@@ -632,8 +632,13 @@ PyObject *PyTep_short_kprobe_print(PyTep *self, PyObject *args,
 
 	ret = tep_register_event_handler(self->ptrObj, id, system, event,
 					 kprobe_info_short, NULL);
+	if (ret < 0) {
+		TfsError_fmt(NULL, "Failed to register handler for event %s/%s (%i).",
+			     system, event, id);
+		return NULL;
+	}
 
-	return PyLong_FromLong(ret);
+	Py_RETURN_NONE;
 }
 
 static bool check_file(struct tracefs_instance *instance, const char *file)
-- 
2.32.0




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux