[libcamera-devel] [PATCH 3/4] libcamera: log: Use internal basename implementation.

Kieran Bingham kieran.bingham at ideasonboard.com
Fri Mar 22 11:43:49 CET 2019


Differing implementations of basename() exist, some of which may modify
the content of the string passed as an argument.

The implementation of basename() is trivial, thus to support different
toolchains, provide our own version which accepts and returns a const
char*.

Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
 src/libcamera/log.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp
index 26ebf410a7a9..7d930cd6b99e 100644
--- a/src/libcamera/log.cpp
+++ b/src/libcamera/log.cpp
@@ -358,6 +358,12 @@ static const char *log_severity_name(LogSeverity severity)
 		return "UNKWN";
 }
 
+static const char *basename(const char *path)
+{
+	const char *base = strrchr(path, '/');
+	return base ? ++base : path;
+}
+
 /**
  * \class LogMessage
  * \brief Internal log message representation.
-- 
2.19.1



More information about the libcamera-devel mailing list