diff mbox series

[2/4] trace-cruncher: Add optional sort to available_system_events()

Message ID 20210831125357.56862-2-y.karadz@gmail.com (mailing list archive)
State Accepted
Headers show
Series [1/4] trace-cruncher: Add optional sort to tfs_list2py_list() | expand

Commit Message

Yordan Karadzhov Aug. 31, 2021, 12:53 p.m. UTC
An optional parameter 'sort' is added. If set to True, the returned
list of event names is sorted in alphabetical order. The default
value of 'sort' is False.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/ftracepy-utils.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c
index 0fcadd8..f884106 100644
--- a/src/ftracepy-utils.c
+++ b/src/ftracepy-utils.c
@@ -733,18 +733,20 @@  PyObject *PyFtrace_available_event_systems(PyObject *self, PyObject *args,
 PyObject *PyFtrace_available_system_events(PyObject *self, PyObject *args,
 							   PyObject *kwargs)
 {
-	static char *kwlist[] = {"system", "instance", NULL};
+	static char *kwlist[] = {"system", "instance", "sort", NULL};
 	struct tracefs_instance *instance;
 	PyObject *py_inst = NULL;
 	const char *system;
+	int sort = false;
 	char **list;
 
 	if (!PyArg_ParseTupleAndKeywords(args,
 					 kwargs,
-					 "s|O",
+					 "s|Op",
 					 kwlist,
 					 &system,
-					 &py_inst)) {
+					 &py_inst,
+					 &sort)) {
 		return NULL;
 	}
 
@@ -757,7 +759,7 @@  PyObject *PyFtrace_available_system_events(PyObject *self, PyObject *args,
 	if (!list)
 		return NULL;
 
-	return tfs_list2py_list(list, false);
+	return tfs_list2py_list(list, sort);
 }
 
 bool get_event_enable_file(struct tracefs_instance *instance,