The string "(nil)" is used to state that an object do not exists / is empty. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx> --- src/common.h | 2 ++ src/ftracepy-utils.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/common.h b/src/common.h index b7f6a87..476e4f1 100644 --- a/src/common.h +++ b/src/common.h @@ -24,6 +24,8 @@ static const char *NO_ARG = "/NONE/"; +#define TC_NIL_MSG "(nil)" + static inline bool is_all(const char *arg) { const char all[] = "all"; diff --git a/src/ftracepy-utils.c b/src/ftracepy-utils.c index da58855..88b069c 100644 --- a/src/ftracepy-utils.c +++ b/src/ftracepy-utils.c @@ -69,7 +69,7 @@ PyObject *PyTepRecord_cpu(PyTepRecord* self) PyObject *PyTepEvent_name(PyTepEvent* self) { - const char * name = self->ptrObj ? self->ptrObj->name : "nil"; + const char *name = self->ptrObj ? self->ptrObj->name : TC_NIL_MSG; return PyUnicode_FromString(name); } @@ -170,7 +170,7 @@ PyObject *PyTepEvent_parse_record_field(PyTepEvent* self, PyObject *args, } if (!field_size) - return PyUnicode_FromString("(nil)"); + return PyUnicode_FromString(TC_NIL_MSG); if (field->flags & TEP_FIELD_IS_STRING) { char *val_str = record->ptrObj->data + field_offset; @@ -2099,7 +2099,7 @@ PyObject *PyFtrace_error_log(PyObject *self, PyObject *args, ret = PyUnicode_FromString(err_log); free(err_log); } else if (ok) { - ret = PyUnicode_FromString("(nil)"); + ret = PyUnicode_FromString(TC_NIL_MSG); } return ret; -- 2.30.2