Message ID | 20200318115846.7975-2-kgupta@es.iitr.ac.in |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Kaaira, On 18/03/2020 11:58, Kaaira Gupta wrote: > Replace the manual string splitting with utils::split() > > Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in> Thanks, I think this really cleans this function up. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > src/libcamera/ipa_proxy.cpp | 15 +++++---------- > 1 file changed, 5 insertions(+), 10 deletions(-) > > diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp > index 5a3d2f1..c7347c8 100644 > --- a/src/libcamera/ipa_proxy.cpp > +++ b/src/libcamera/ipa_proxy.cpp > @@ -83,21 +83,16 @@ std::string IPAProxy::resolvePath(const std::string &file) const > > /* No exec target in install directory; check env variable. */ > const char *execPaths = utils::secure_getenv("LIBCAMERA_IPA_PROXY_PATH"); > - while (execPaths) { > - const char *delim = strchrnul(execPaths, ':'); > - size_t count = delim - execPaths; > + if (execPaths) { > + for (const auto &dir : utils::split(execPaths, ":")) { > + if (dir.empty()) > + continue; > > - if (count) { > - std::string proxyPath(execPaths, count); > + std::string proxyPath = dir; > proxyPath += proxyFile; > if (!access(proxyPath.c_str(), X_OK)) > return proxyPath; > } > - > - if (*delim == '\0') > - break; > - > - execPaths += count + 1; > } > > return std::string(); >
diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index 5a3d2f1..c7347c8 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -83,21 +83,16 @@ std::string IPAProxy::resolvePath(const std::string &file) const /* No exec target in install directory; check env variable. */ const char *execPaths = utils::secure_getenv("LIBCAMERA_IPA_PROXY_PATH"); - while (execPaths) { - const char *delim = strchrnul(execPaths, ':'); - size_t count = delim - execPaths; + if (execPaths) { + for (const auto &dir : utils::split(execPaths, ":")) { + if (dir.empty()) + continue; - if (count) { - std::string proxyPath(execPaths, count); + std::string proxyPath = dir; proxyPath += proxyFile; if (!access(proxyPath.c_str(), X_OK)) return proxyPath; } - - if (*delim == '\0') - break; - - execPaths += count + 1; } return std::string();
Replace the manual string splitting with utils::split() Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in> --- src/libcamera/ipa_proxy.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)