.gitreview | 2 +- sal/osl/unx/file.cxx | 11 ++++++----- sal/osl/unx/file_misc.cxx | 4 ++-- sal/osl/unx/pipe.cxx | 2 +- sal/qa/osl/file/osl_File.cxx | 10 +++++++--- 5 files changed, 17 insertions(+), 12 deletions(-)
New commits: commit cc0d44165ee57a2aca900dc69b0961cf9cc22395 Author: Miklos Vajna <[email protected]> AuthorDate: Fri Feb 9 14:06:54 2024 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Fri Feb 9 15:08:30 2024 +0100 sal: fix some clang plugin warnings See <https://cpci.cbg.collabora.co.uk:8080/job/gerrit_linux_co-24.04_clang_dbgutil/36/console>. For some conversion examples, see commit 71337b4327805b73e92c995153c5746d89793b13 (use more string_view in sw, 2022-10-11). 'make sal.allcheck' now passes with this. Change-Id: I13d110900f887985081a8752ed241c040fb1ee1a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163169 Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Miklos Vajna <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/.gitreview b/.gitreview index b19dbd6215d2..61b8cfb51501 100644 --- a/.gitreview +++ b/.gitreview @@ -3,5 +3,5 @@ host=gerrit.libreoffice.org port=29418 project=core defaultremote=logerrit -defaultbranch=distro/collabora/co-24.`4 +defaultbranch=distro/collabora/co-24.04 diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index 213dc6ab53de..1bfb0c72f089 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" @@ -789,14 +790,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.rfind('/'); OString folderPath; if (n < 1) - folderPath = "."; + folderPath = "."_ostr; else - folderPath = rFilePath.copy(0, n); + folderPath = OString(rFilePath.substr(0, n)); return folderPath; } @@ -818,7 +819,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 69ca29cdbaa4..9b39d5973c83 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 @@ -562,7 +562,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; // const_cast because sys_path is a local copy which we want to modify inplace instead of diff --git a/sal/osl/unx/pipe.cxx b/sal/osl/unx/pipe.cxx index 62897552ed41..44535c61d29f 100644 --- a/sal/osl/unx/pipe.cxx +++ b/sal/osl/unx/pipe.cxx @@ -210,7 +210,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; diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx index df59f33e6070..3517f4911acc 100644 --- a/sal/qa/osl/file/osl_File.cxx +++ b/sal/qa/osl/file/osl_File.cxx @@ -1401,15 +1401,18 @@ namespace osl_Forbidden void open() { +#if 0 File::setAllowedPaths(maScratchGood); File testFile(maScratchBad + "/open"); auto nError1 = testFile.open(osl_File_OpenFlag_Read | osl_File_OpenFlag_Write); CPPUNIT_ASSERT_EQUAL_MESSAGE("disabled path allowed", osl::FileBase::E_ACCES, nError1); deleteTestFile(testFile.getURL()); +#endif } void copy() { +#if 0 File::setAllowedPaths("w:" + maScratchGood); File testGood(maScratchGood + "/good"); File testGoodTo(maScratchGood + "/good_to"); @@ -1426,6 +1429,7 @@ namespace osl_Forbidden deleteTestFile(maScratchGood + "/good_to"); deleteTestFile(maScratchGood + "/good"); +#endif } void nextTests() @@ -1444,9 +1448,9 @@ namespace osl_Forbidden CPPUNIT_TEST_SUITE(Forbidden); CPPUNIT_TEST(forbidden); -// CPPUNIT_TEST(open); -// CPPUNIT_TEST(copy); -// CPPUNIT_TEST(nextTests); + CPPUNIT_TEST(open); + CPPUNIT_TEST(copy); + CPPUNIT_TEST(nextTests); CPPUNIT_TEST_SUITE_END(); };
