[libcamera-devel] [PATCH 3/4] libcamera: log: Use internal basename implementation.
Kieran Bingham
kieran.bingham at ideasonboard.com
Mon Mar 25 17:09:30 CET 2019
Hi Laurent,
On 22/03/2019 23:05, Laurent Pinchart wrote:
> Hi Kieran,
>
> Thank you for the patch.
>
> On Fri, Mar 22, 2019 at 10:43:49AM +0000, Kieran Bingham wrote:
>> Differing implementations of basename() exist, some of which may modify
>
> s/Differing/Different/ ?
I can change this if you like, but Differing makes sense to me...
There are multiple implementations in existence, and they differ.
And here we add 'another' implementation because of it :-)
>> 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;
>
> I'd write
>
> return base ? base + 1 : path;
As you wish.
>
>> +}
>> +
>
> Should this go to utils.h ?
It can do - but then I have to also modify the call site.
Updated.
>> /**
>> * \class LogMessage
>> * \brief Internal log message representation.
>
--
Regards
--
Kieran
More information about the libcamera-devel
mailing list