diff mbox series

[2/3] trace-cruncher: Have standard 'not existing' message

Message ID 20210823125348.145615-2-y.karadz@gmail.com (mailing list archive)
State Superseded
Headers show
Series [1/3] trace-cruncher: Add methods for accessing tracefs errorlog | expand

Commit Message

Yordan Karadzhov Aug. 23, 2021, 12:53 p.m. UTC
The string "(nil)" is used to state that an object
do not exists / is empty.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 src/common.h         | 2 ++
 src/ftracepy-utils.c | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

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 a3ae03a..4561a4d 100644
--- a/src/ftracepy-utils.c
+++ b/src/ftracepy-utils.c
@@ -68,7 +68,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);
 }
 
@@ -169,7 +169,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;
@@ -2098,7 +2098,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;