[libcamera-devel] [PATCH] log: Use libgen implementation of basename

Kieran Bingham kieran.bingham at ideasonboard.com
Fri Dec 14 09:59:09 CET 2018


Pull in the libgen header to define basename. Unfortuantely this
requires casting away the const flag on the filename.

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

diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp
index 3715e69d810e..7096071e53f6 100644
--- a/src/libcamera/log.cpp
+++ b/src/libcamera/log.cpp
@@ -9,6 +9,7 @@
 #include <ctime>
 #include <iomanip>
 #include <string.h>
+#include <libgen.h>
 
 #include "log.h"
 #include "utils.h"
@@ -80,7 +81,7 @@ LogMessage::LogMessage(const char *fileName, unsigned int line,
 		  << std::setw(9) << timestamp.tv_nsec << "]";
 
 	msgStream << " " << log_severity_name(severity);
-	msgStream << " " << basename(fileName) << ":" << line << " ";
+	msgStream << " " << basename((char *)fileName) << ":" << line << " ";
 }
 
 LogMessage::~LogMessage()
-- 
2.17.1



More information about the libcamera-devel mailing list