An optional parameter 'sort' is added. If set to True, the returned list of system names is sorted in alphabetical order. The default value of 'sort' is False. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx> --- src/ftracepy-utils.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c index f884106..b94745d 100644 --- a/src/ftracepy-utils.c +++ b/src/ftracepy-utils.c @@ -717,17 +717,29 @@ PyObject *PyFtrace_get_current_tracer(PyObject *self, PyObject *args, PyObject *PyFtrace_available_event_systems(PyObject *self, PyObject *args, PyObject *kwargs) { + static char *kwlist[] = {"instance", "sort", NULL}; struct tracefs_instance *instance; + PyObject *py_inst = NULL; + int sort = false; char **list; - if (!get_instance_from_arg(args, kwargs, &instance)) + if (!PyArg_ParseTupleAndKeywords(args, + kwargs, + "|Op", + kwlist, + &py_inst, + &sort)) { + return false; + } + + if (!get_optional_instance(py_inst, &instance)) return NULL; list = tracefs_event_systems(tracefs_instance_get_dir(instance)); if (!list) return NULL; - return tfs_list2py_list(list, false); + return tfs_list2py_list(list, sort); } PyObject *PyFtrace_available_system_events(PyObject *self, PyObject *args, -- 2.30.2