summaryrefslogtreecommitdiff
path: root/sal
AgeCommit message (Collapse)Author
2021-02-16tdf#137208 Assume that dladdr provides an absolute pathnameStephan Bergmann
3dfb38a45d6495d357c3359b5b02cde871df6f67 "added getUrlFromAddress (#88338#)" had introduced the call to osl_getAbsoluteFileURL for no documented reason, but it looks unlikely that any relevant implementation of dladdr (as called by getModulePathFromAddress; and where dladdr is a non-POSIX extension on the various platforms) would provide pathnames that are relative to the process's CWD. (Instead, add a check whether osl_getFileURLFromSystemPath succeeds.) Change-Id: If291e9fdf63fc3f42ba7c7e3138d7db5328ed165 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111004 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-02-16Remove dead "defined(ANDROID) && !defined(DISABLE_DYNLOADING)" codeStephan Bergmann
4b7e701024219be48b7f8154a508c79cb0a6fdc1 "Use DISABLE_DYNLOADING on Android" has removed lo_dladdr, so this conditional code is apparently dead, and its clean-up was presumably forgotten in that commit. Change-Id: Icf8e4056366f90837c48dd2fcf45936f8015eb43 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110981 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-02-15Do not remove '/' when it's the only character in the pathMike Kaganski
Follow-up to commit 3380163bc0fb9dab7f289cc36b0eeb0c9b3ddaa9. Change-Id: I5e895755cb4b2432c8ac423d254f493764dead75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110899 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-02-15Reuse known length of the temp dir pathMike Kaganski
And make this code a bit more C++-ish. Change-Id: I59d4f46698ad4606f09e6ffcae8f205798b427ea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110912 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-02-12Make sure osl_getTempDirURL result doesn't end with / also on unxMike Kaganski
This is consistent with what osl_getTempDirURL does on Windows This is a blind attempt to fix a part of a failure reported on IRC: /lode/dev/core/sal/qa/osl/file/osl_File.cxx:486: Assertion Test name: osl_FileBase::getAbsoluteFileURL::getAbsoluteFileURL_001_1 equality assertion failed - Expected: file:///var/folders/tj/jl7sh26124n4b94tm541m6xr0000gn/T//relative/file1 - Actual : file:///private/var/folders/tj/jl7sh26124n4b94tm541m6xr0000gn/T/relative/file1 - Assumption is wrong: ResultURL is not equal to expected URL That "//" in Expected might be because user's TMPDIR ends with /. Change-Id: I9a9c6e00f63b81dbaf2e8532110dffa58ebe8cc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110784 Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Tested-by: Jenkins
2021-02-12Make sure to resolve symlinks in temp path in path testsMike Kaganski
This is a blind attempt to fix a part of a failure reported on IRC: /lode/dev/core/sal/qa/osl/file/osl_File.cxx:486: Assertion Test name: osl_FileBase::getAbsoluteFileURL::getAbsoluteFileURL_001_1 equality assertion failed - Expected: file:///var/folders/tj/jl7sh26124n4b94tm541m6xr0000gn/T//relative/file1 - Actual : file:///private/var/folders/tj/jl7sh26124n4b94tm541m6xr0000gn/T/relative/file1 - Assumption is wrong: ResultURL is not equal to expected URL That "private/" in Expected might be because user's /var is a symlink to /private/var. Change-Id: Ia5b95621dffdae7e0193aca4c3d12c86ed28dceb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110785 Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Tested-by: Jenkins
2021-02-10Fix creation of some OUString from non-ASCII ordinary string literalsStephan Bergmann
On platforms where char is signed, > OUString aTmpName10(aTempDirectoryURL + "/\xE6\x9C\xAA\xE5\x91\xBD\xE5\x90\x8Dzhgb18030"); would have created, via addDataLiteral (include/rtl/stringconcat.hxx), an OUString containing sign-extended char16_t counterparts of the \x char values (\xE6 -> \uFFE6, etc.). That caused CppunitTest_sal_osl CPPUNIT_TEST_NAME=osl_FileBase::SystemPath_FileURL::getSystemPathFromFileURL_005 under an RTL_TEXTENCODING_ISO_8859_1 locale (e.g., LANG=C, as used by Fedora when executing the %check part of libreoffice.spec) to fail on such signed-char platforms (e.g., Linux x86_64) with > [_RUN_____] osl_FileBase::SystemPath_FileURL::getSystemPathFromFileURL_005 > createTestDirectory failed: 21! > sal/qa/osl/file/osl_File.cxx:267:osl_FileBase::SystemPath_FileURL::getSystemPathFromFileURL_005 > assertion failed > - Expression: (osl::FileBase::E_None == nError) || (nError == osl::FileBase::E_NOENT) > - In deleteTestDirectory function: remove Directory file:///tmp/?????????zhgb18030 -> result: 21 because FileURLToPath -> osl::detail::convertUrlToPathname -> getSystemPathFromFileUrl<rtl::OString> -> decodeFromUtf8 -> convert (all sal/osl/unx/file_url.cxx) would fail to convert those values beyond \u00FF to RTL_TEXTENCODING_ISO_8859_1, ultimately returning osl_File_E_INVAL (i.e., 21). (We could "fix" addDataLiteral in include/rtl/stringconcat.hxx, explicitly converting from char to char16_t via unsigned char, but arguably that concatenation construct should only be used with ASCII-only ordinary string literals, similar to the restrictions for OUString construction from such string literals.) (Before 5a77636c9a638c86fd3de3afb6e88cf48f987b6a "WIN enable osl_File.cxx part of CppUnitTest_sal_osl", that aTmpName10 was constructed as > OUString aTmpName10(RTL_CONSTASCII_USTRINGPARAM( FILE_PREFIX TEST_PLATFORM TEST_PLATFORM_TEMP "/\xE6\x9C\xAA\xE5\x91\xBD\xE5\x90\x8Dzhgb18030" )); but that would have caused similar issues, as RTL_CONSTASCII_USTRINGPARAM uses RTL_TEXTENCODING_ASCII_US which converts non-ASCII chars to RTL_TEXTENCODING_MS_1252 (see comment at aImplUSASCIIByteCvtData, sal/textenc/textenc.cxx), which would have converted e.g. \x9C to \u2018, which then would have failed to be converted to RTL_TEXTENCODING_ISO_8859_1. And that use of RTL_CONSTASCII_USTRINGPARAM had violated the requirements as stated in include/rtl/ustring.h anyway: "Each element of the referenced array must represent an ASCII value in the range 0x00--0x7F.") Whatever this crappy getSystemPathFromFileURL_005 actually wants to prove, it happens to work now also for RTL_TEXTENCODING_ISO_8859_1 locales. Change-Id: I044c4bd3aee4f7ea4f29737b6876cc55e4e6e436 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110714 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-02-10use zlib crc32() rather our own implementationLuboš Luňák
They compute the same thing, only zlib can do it four bytes at once. Since crc32() is used when loading documents, with larger documents this is a difference than can be measured (not much, but a couple percent of loading time). And we already depend on zlib anyway. Change-Id: I65c5a1f050af717a5a2d6e334e216d42c4e4dbbb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110651 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2021-02-10Be a bit more verbose in that crappy test codeStephan Bergmann
Change-Id: Ic0500db292d52a827f2139cd2cbbc0e8e4274dac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110701 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-02-10Fix dependency of CppunitTest_sal_osl on CppunitTest_Module_DLL libraryStephan Bergmann
The former only depends on the latter's library, not on actually running the latter test. (Something like > $ make CppunitTest_sal_osl CPPUNIT_TEST_NAME=osl_FileBase::SystemPath_FileURL::getSystemPathFromFileURL_005 > make -j 12 -rs -f Makefile.gbuild CppunitTest_sal_osl > [CUT] Module_DLL > > Fatal error: CPPUNIT_TEST_NAME contains no valid tests > > Error: a unit test failed, please do one of: > > make CppunitTest_Module_DLL CPPUNITTRACE="gdb --args" > # for interactive debugging on Linux > make CppunitTest_Module_DLL VALGRIND=memcheck > # for memory checking > make CppunitTest_Module_DLL DEBUGCPPUNIT=TRUE > # for exception catching > > You can limit the execution to just one particular test by: > > make CPPUNIT_TEST_NAME="testXYZ" ...above mentioned params... > > make[1]: *** [solenv/gbuild/CppunitTest.mk:125: workdir/CppunitTest/Module_DLL.test] Error 1 > make: *** [Makefile:166: CppunitTest_sal_osl] Error 2 thus used to fail rather unexpectedly.) Change-Id: Id6051b192679d598100bbb5eae854bef59af9f44 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110698 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-02-10Fix loplugin:stringliteralvarStephan Bergmann
...detection of OUString( const sal_Unicode * value, sal_Int32 length ) ctor. (On platforms where sal_Int32 is a typedef for int, an argument that already is of type int will not be wrapped in an ImplicitCastExpr to the sal_Int32 typedef.) Change-Id: Ifc5456a62d42c1acad76ea949549dc24bd67201a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110654 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-02-09loplugin:fakebool followed by loplugin:implicitboolconversion (clang-cl)Stephan Bergmann
Change-Id: I0f61268b2027eb617b2312615ea544387af1b381 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110643 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-02-09report what value was found in messageCaolán McNamara
Change-Id: I512cedcd46f829b97b62a57d90d5a4a81d024d66 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110562 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-02-08Remove unneeded breaksAndrea Gelmini
Extending this: https://gerrit.libreoffice.org/c/core/+/110512 Change-Id: I1c5bfcddeb0f5619dc848bbf02408cf166bebc8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110521 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2021-02-08Improve loplugin:cppunitassertequal for CPPUNIT_ASSERT(a && b)Stephan Bergmann
...by re-enabling the code temporarily #if'ed-out in a528392e71bc70136021be4e3d83732fccbb885e "Fixed/improved loplugin:cppunitassertequals" (and which then triggers lots of other lopglugin:cppunitassertequal CPPUNIT_ASSERT -> CPPUNIT_ASSERT_EQUAL warnings). For two css::uno::Reference equality comparisons in cppu/qa/test_any.cxx, it was more straightforward to rewrite them with an explicit call to operator == (which silences loplugin:cppunitassertequal) than to adapt them to CPPUNIT_ASSERT_EQUAL's requirement for arguments of identical types. In sc/qa/unit/ucalc_pivottable.cxx, ScDPItemData needs toString, which has been implemented trivially for now, but might want to combine that with the DEBUG_PIVOT_TABLE-only ScDPItemData::Dump. Change-Id: Iae6d09cf69bd4e52fe4411bba9e50c48e696291c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110546 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-02-05Revert "Fix typo in code"Stephan Bergmann
This reverts commit 3ed9bba283a6a67864c0928186e277240be0d9ba. osl_Pos_Absolut (include/osl/file.h) is part of the stable URE interface; it must not be changed. Change-Id: I1f49923a9351e4be5aee39b10720d38b424feb9b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110435 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-02-05osl_File checks: creation in root can also fail because of read-only filesystemChristian Lohmaier
80b7949016fbc6addd54bf9f6cf300c756fd0f8a enabled a bunch of previously disabled checks, but on m1 macs osl_File::open::open_004 fails the assert, because it doesn't fail with E_ACCES, but with E_ROFS. (probably nothing to do with apple silicon, but rather because of Big Sur and using apfs as filesystem) Change-Id: Ibd2168ba5fb9d859ea339713099c9bc8a799fcc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110431 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2021-02-04Fix typo in codeAndrea Gelmini
Change-Id: Ib8b306a27d25a34e784aeeb72708b0d5d1511f3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110394 Tested-by: Jenkins Reviewed-by: Andrea Gelmini <andrea.gelmini@gelma.net>
2021-02-03Enable previously disabled file and directory testsMike Kaganski
Change-Id: If94a492fa8ef2167bb4c767802e8ea92405a59e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110337 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-02-02Do not forget to remove "." and ".." path parts in osl_getAbsoluteFileURLMike Kaganski
A follow-up to commit 6e0fa7d4c7b45c98418c289d1d4715eb9eb133f7. Also enables corresponding unit tests on Windows. Change-Id: I250d1269e06c8ce11ebc0e4ea12171c5755aa42d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110273 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-02-01Drop FAR/NEAR from 16-bit WinAPI timesMike Kaganski
Change-Id: Idf71c662138c281333a83cc76a9d75cbf086f362 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110236 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-01-31Fix typosAndrea Gelmini
Change-Id: Id81d2876dc6ead2de03c21e35b7940fee35bc773 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110176 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2021-01-31Use C++ thread_local instead of Tls* WinAPIMike Kaganski
Change-Id: I9fdbd6ba0e9b94f286a896053b837e58c75135d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110175 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-01-30Simplify osl_getGlobalMutex to use function-local staticMike Kaganski
Change-Id: I36df8be817d0f0cb75efa00b0b523f379f67d1d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110126 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-01-30Reinstate still relevant bits of commentMike Kaganski
... removed in commit 6e0fa7d4c7b45c98418c289d1d4715eb9eb133f7. Change-Id: I6a58ad9d676a5f4b6f654e114eb640d7f82682c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110164 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-01-30Use function-local static Mutex here instead of global CRITICAL_SECTIONMike Kaganski
Our Mutes uses sritical sections on Windows anyway Change-Id: Ieb4a8431700215758aaf84dc7a8c2db4b4030804 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110158 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-01-30Don't change process current directory in osl_getAbsoluteFileURLMike Kaganski
This removes the need to synchronize using global mutex, and allows to get correct result when base directory is unavailable. Change-Id: I9ae70a7d0e8f0840a533a2d0d222336cc0bf0b4e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110163 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-01-29Use OUString and its fast concat instead of C string manipulationMike Kaganski
Change-Id: I5c0071460855317024ab6f61e6b3010d12546227 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110128 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-01-29Use MutexGuard instead of direct oslMutex manipulationsMike Kaganski
Change-Id: Ifb2b309e2ffe51e491da83f64c12d9c0956fed4f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110127 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2021-01-28simplify code, use more subView()Noel
Change-Id: I569c7f34acbdf8451cd5c9acf1abd334637072d1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110051 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-01-28add string_view variants of methods to O[U]StringBufferNoel
and update the stringview loplugin to detect cases where we can use these new methods. Change-Id: I998efe02e35c8efcb3abfb4d7186165bbe6dfb2c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110046 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2021-01-27Improve loplugin:stringliteralvarStephan Bergmann
...to also consider O[U]String ctors taking pointer and length Change-Id: Iea5041634bfbf5054a1317701e30b56f72e940fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110025 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-01-17cppcheck: zerodivcondJulien Nabet
I don't know if it can happen or if it's a false positive but at least, we're sure now it won't fail Change-Id: Id4620d74c0893b308b9fb45be71ca6c425066ae4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109470 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2021-01-15OUString::matchAsciiL() can be used instead of the fresh startsWithAsciiL()Tor Lillqvist
Revert the addition of the latter. Change-Id: I93636a901cde401b0b7d923e052887f57dd58212 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109315 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
2021-01-14Introduce startsWithAsciiL() to match endsWithAsciiL()Tor Lillqvist
Will be used in an upcoming change. Unit test included. Change-Id: I777a755cab543ea277b84fb5ad021d0b91725764 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109264 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
2021-01-10fix coverity parse errorsCaolán McNamara
Change-Id: I4884bfb67a061b865e8cf38b2fea6de0cb1bc3d6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109057 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2021-01-10Missing include guard in new sal/rtl/strtmpl.hxxStephan Bergmann
...as causing trouble in ASan/UBSan builds, > [CXX] jurt/source/pipe/staticsalhack.cxx > In file included from jurt/source/pipe/staticsalhack.cxx:20: > In file included from sal/rtl/ustring.cxx:51: > sal/rtl/strtmpl.hxx:38:28: error: redefinition of 'IMPL_RTL_USTRCODE' > template <typename C> auto IMPL_RTL_USTRCODE(C c) { return std::make_unsigned_t<C>(c); } > ^ > sal/rtl/strtmpl.hxx:38:28: note: previous definition is here > template <typename C> auto IMPL_RTL_USTRCODE(C c) { return std::make_unsigned_t<C>(c); } > ^ [...] Change-Id: Ied38a5f96bbb6d1c0d8ae956629ca6be64dc273f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109055 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-01-10Replace strtmpl.cxx with actual C++ templates in strtmpl.hxxMike Kaganski
This has at least better IDE support, with easier lookup for function implementations. Change-Id: I0e4cfe40df036efa796c057852bd5cb4421507f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108931 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2020-12-26New loplugin:stringliteralvarStephan Bergmann
See the comment at the top of compilerplugins/clang/stringliteralvar.cxx for details. (Turned some affected variables in included files into inline variables, to avoid GCC warnings about unused variables.) Change-Id: Ie77219e6adfdaaceaa8b4e590b08971f2f04c83a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108239 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-23Use char16_t string literalsStephan Bergmann
Change-Id: I0a8b577957ac1d4cad5fc1163f244012a8391a77 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108216 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-20Remove the OUString vs. std::u16string_view comparison operators againStephan Bergmann
...that were introduced in e6dfaf9f44f9939abc338c83b3024108431d0f69 "Turn OUStringLiteral into a consteval'ed, static-refcound rtl_uString" to avoid ambiguities, but which is no longer an issue since 46c5de832868d2812448b2caace3eeaa9237b9f6 "make *String(string_view) constructors explicit" Change-Id: I0a7a3fe23412f77fa85fb7e90f04e22f9abd9230 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108044 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-18Check intermediate for not to be rounded value, tdf#138360 follow-upEike Rathke
Change-Id: I98cc25267e7a10c34179bab50d19f49436e1c48c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107929 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
2020-12-18Replace log2() call with parts.exponent-1023, tdf#138360 follow-upEike Rathke
... to save some cycles as we anyway need only the integer value of the exponent and even exactly this value for the number of possible decimals. Change-Id: I8d462f53cadde6a95d57d1342d8487fbfa001ae9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107928 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
2020-12-14Add empty OUStringBuffer::toString testStephan Bergmann
...motivated by <https://gerrit.libreoffice.org/c/core/+/107643> "Don't crash on an empty OUStringBuffer::toString" Change-Id: I144f0814f585f56df3fcdc818fd8c5e18ad08115 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107672 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-11Adapt the remaining OUString functions to std string_viewStephan Bergmann
...for LIBO_INTERNAL_ONLY. These had been missed by 1b43cceaea2084a0489db68cd0113508f34b6643 "Make many OUString functions take std::u16string_view parameters" because they did not match the multi-overload pattern that was addressed there, but they nevertheless benefit from being changed just as well (witness e.g. the various resulting changes from copy() to subView()). This showed a conversion from OStringChar to std::string_view to be missing (while the corresponding conversion form OUStringChar to std::u16string_view was already present). The improvement to loplugin:stringadd became necessary to fix > [CPT] compilerplugins/clang/test/stringadd.cxx > error: 'error' diagnostics expected but not seen: > File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 43 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:42): simplify by merging with the preceding assignment [loplugin:stringadd] > File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 61 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:60): simplify by merging with the preceding assignment [loplugin:stringadd] > 2 errors generated. Change-Id: Ie40de0616a66e60e289c1af0ca60aed6f9ecc279 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107602 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-10Avoid calling OString ctor with null pointerStephan Bergmann
...in preparation of potential future changes from using OString to using std::string_view, where OString has an undocumented feature of allowing construction from a null pointer. This is mostly the result of a manual audit of potentially problematic getenv calls across the code base. But there can be other problematic places too, like the xmlGetProp call in tools/source/xml/XmlWalker.cxx. To identify those, rtl_{string,uString}_newFromStr aborts now in non-production debug builds when a null pointer is passed(and all places that hit with a full `make check screenshot` have been addressed here). Once we are confident that all problematic places have been identified, we should drop support for the undocumented feature (see the TODO in sal/rtl/strtmpl.cxx). Change-Id: I595cc6d4f1cda74add2a3db171323f817d362b08 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107430 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-10Do not call GetAddrInfoW if we just want the hostnameSamuel Mehrbrodt
Calling 'gethostname' already gives us the current host name on Windows. For some reason, if that name does not contain a dot, GetAddrInfoW is called, which "provides protocol-independent translation from a Unicode host name to an address". So all this function does, is returning an address for a hostname, while we still only need the hostname and not the address. This causes a lag when creating the lockfile on opening a document if the network is flaky/disabled. See tdf#97931 and tdf#47179 for some problems caused by this. Change-Id: I0c543ea12c23506b2daa50da40bae1a471f6fe16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107513 Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2020-12-08Tighten rtl_{string,uString}_newFromStr_WithLength implementationStephan Bergmann
While the documented interface was already narrow (or at least didn't suggest that the length argument could reasonably be negative), the implementation was somewhat broader: For one, it allowed the character pointer to be null even when the length was non-zero, which looks more like a call-site bug than like a useful feature. And for another, while it did assert that the length is non- negative, it nevertheless then checked "overly defensively" for <= 0 rather than == 0 down the road. Change-Id: I084148aaa4b9c4aea16729b0ce90b73ccbe73ebe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107425 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-08Improve a CPPUNIT_ASSERT messageStephan Bergmann
Change-Id: Ia40f249a115a8c4fe01fb384041b4542735166c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107418 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-12-07Revert "Fix osl_Security::getHomeDir test under fakeroot"Stephan Bergmann
This reverts commit c8098382da6a7a0448ff8051cac467f91d7e0b36. Conflicts: sal/qa/osl/security/osl_Security.cxx There should be no good reason to run unit tests like CppunitTest_sal_osl_security under fakeroot, esp. not since a58e086ededb8442938e81f971dfae36ef7eb076 "rework the default make target" no longer runs them as part of a plain `make`. (And getting rid of this code means one less place to audit for nullptr issues with getenv in combination with potential OString -> std::string_view changes.) Change-Id: I6bba0ed28ea1ba894ee182f8bda35aad69a54dc6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107336 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>