sal/osl/unx/file.cxx | 11 ++++++----- sal/osl/unx/file_misc.cxx | 4 ++-- sal/osl/unx/pipe.cxx | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-)
New commits: commit 52e0838a8f35837a92e7b0277544995e477fe8b6 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Mar 12 13:13:53 2025 +0100 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Wed Mar 12 13:44:53 2025 +0100 sal: fix various clang loplugin warnings /home/vmiklos/git/libreoffice/co-25.04-clang/sal/osl/unx/file.cxx:863:20: error: rather than getToken, pass with a view using o3tl::getToken() [loplugin:stringview] aPaths.getToken(0, ':', nIndex), ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ /home/vmiklos/git/libreoffice/co-25.04-clang/sal/osl/unx/file.cxx:839:20: error: use a _ostr user-defined string literal instead of assigning from an ordinary string literal [loplugin:ostr] folderPath = "."; ~~~~~~~~~~~^~~~~ /home/vmiklos/git/libreoffice/co-25.04-clang/sal/osl/unx/file.cxx:834:47: error: replace function parameter of type 'const rtl::OString &' with 'std::string_view' [loplugin:stringviewparam] static OString getParentFolder(const OString &rFilePath) ~~~~~~~~~~~~~~~^~~~~~~~~ 3 errors generated. Change-Id: Ide538e334986777b0282d298740dbed43df73926 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182821 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index 5a87da0658f9..96f4633e42b0 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -24,6 +24,7 @@ #include <osl/detail/file.h> #include <rtl/byteseq.h> #include <rtl/string.hxx> +#include <o3tl/string_view.hxx> #include "system.hxx" #include "createfilehandlefromfd.hxx" @@ -831,14 +832,14 @@ static std::vector<OString> allowedPathsRead; static std::vector<OString> allowedPathsReadWrite; static std::vector<OString> allowedPathsExecute; -static OString getParentFolder(const OString &rFilePath) +static OString getParentFolder(std::string_view rFilePath) { - sal_Int32 n = rFilePath.lastIndexOf('/'); + sal_Int32 n = rFilePath.find_last_of('/'); OString folderPath; if (n < 1) - folderPath = "."; + folderPath = "."_ostr; else - folderPath = rFilePath.copy(0, n); + folderPath = OString(rFilePath.substr(0, n)); return folderPath; } @@ -860,7 +861,7 @@ SAL_DLLPUBLIC void osl_setAllowedPaths( do { OString aPath = rtl::OUStringToOString( - aPaths.getToken(0, ':', nIndex), + o3tl::getToken(aPaths, 0, ':', nIndex), RTL_TEXTENCODING_UTF8); if (aPath.getLength() == 0) diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx index ddaacc9d79fa..500a26a042b2 100644 --- a/sal/osl/unx/file_misc.cxx +++ b/sal/osl/unx/file_misc.cxx @@ -143,7 +143,7 @@ oslFileError SAL_CALL osl_openDirectory(rtl_uString* ustrDirectoryURL, oslDirect osl_systemPathRemoveSeparator(path.pData); - if (isForbidden(path.getStr(), osl_File_OpenFlag_Read)) + if (isForbidden(path, osl_File_OpenFlag_Read)) return osl_File_E_ACCES; #ifdef MACOSX @@ -559,7 +559,7 @@ oslFileError SAL_CALL osl_createDirectoryPath( osl::systemPathRemoveSeparator(sys_path); - if (isForbidden(sys_path.getStr(), osl_File_OpenFlag_Create)) + if (isForbidden(sys_path, osl_File_OpenFlag_Create)) return osl_File_E_ACCES; return create_dir_recursively_(sys_path.pData->buffer, aDirectoryCreationCallbackFunc, pData); diff --git a/sal/osl/unx/pipe.cxx b/sal/osl/unx/pipe.cxx index ee6f852eef4a..daeb0e65572c 100644 --- a/sal/osl/unx/pipe.cxx +++ b/sal/osl/unx/pipe.cxx @@ -207,7 +207,7 @@ static oslPipe osl_psz_createPipe(const char *pszPipeName, oslPipeOptions Option SAL_INFO("sal.osl.pipe", "new pipe on fd " << pPipe->m_Socket << " '" << name << "'"); - if (isForbidden(name.getStr(), osl_File_OpenFlag_Create)) + if (isForbidden(name, osl_File_OpenFlag_Create)) return nullptr; addr.sun_family = AF_UNIX;