Message ID | 20190322104350.31091-4-kieran.bingham@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
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/ ? > 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@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; > +} > + Should this go to utils.h ? > /** > * \class LogMessage > * \brief Internal log message representation.
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@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. >
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.
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@ideasonboard.com> --- src/libcamera/log.cpp | 6 ++++++ 1 file changed, 6 insertions(+)