summaryrefslogtreecommitdiff
path: root/sal/osl/unx
AgeCommit message (Collapse)Author
2020-05-09android: file-cache to improve performance.Michael Meeks
The transition to java - interestingly to free the passed buffer was showing on profiles. Change-Id: Id1f4f6e60896c3f42fcbf761e535b68318e0a0a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86164 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2020-05-06Fix problems when running a sandboxed LO as X.app/Contents/MacOS/sofficeTor Lillqvist
The argv[0] passed to osl_setCommandArgs will then be the relative path and osl::realpath() will fail. Instead, use bootstrap_getExecutableFile() which calls _NSGetExecutablePath() to get the executable's pathname for g_command_args. Change-Id: I1345afe158d7b64871f6340733fb5490d5ca6bd8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93438 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2019-10-21size some stringbuffer to prevent re-allocNoel Grandin
found by the simple expidient of putting asserts in the resize routine. Where an explicit const size is used, I started with 32 and kept doubling until that site did not need resizing anymore. Change-Id: I998787edc940d0a3ba23b5ac37131ab9ecd300f4 Reviewed-on: https://gerrit.libreoffice.org/81138 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-18cid#1448512 silence Out-of-bounds accessCaolán McNamara
Change-Id: I3e5efb9be471814b5dabf501feb93a65e9b5bcd3 Reviewed-on: https://gerrit.libreoffice.org/81022 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-10-14New loplugin:getstrStephan Bergmann
...to find matches of ... << s.getStr() (for the rtl string classes) that can be written as just ... << s Some notes: * The OUStringToOString(..., RTL_TEXTENCODING_UTF8) is left explicit in desktop/source/app/crashreport.cxx (even though that would also be done internally by the "<< OUString" operator) to clarify that these values are written out as UTF-8 (and not as what that operator << happens to use, which just also happens to be UTF-8). * OUSTRING_TO_CSTR (include/oox/helper/helper.hxx) is no longer used now. * Just don't bother to use osl_getThreadTextEncoding() in the SAL_WARN in lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx. * The toUtf8() in the SAL_DEBUG in pyuno/source/module/pyuno_module.cxx can just go, too. Change-Id: I4602f0379ef816bff310f1e51b57c56b7e3f0136 Reviewed-on: https://gerrit.libreoffice.org/80762 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-14loplugin:stringadd look for unnecessary temporariesNoel Grandin
which defeat the *StringConcat optimisation. Also make StringConcat conversions treat a nullptr as an empty string, to match the O*String(char*) constructors. Change-Id: If45f5b4b6a535c97bfeeacd9ec472a7603a52e5b Reviewed-on: https://gerrit.libreoffice.org/80724 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-10DestFileExists should be boolStephan Bergmann
Change-Id: I5803aa2498654c579f9fe6293e5204aa63edd589 Reviewed-on: https://gerrit.libreoffice.org/80607 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-09cid#1453854 silence Time of check time of useCaolán McNamara
Change-Id: Icfa358476db3166c29e893c09ec943aa3c38dba3 Reviewed-on: https://gerrit.libreoffice.org/80520 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-10-07cid#1448512 silence bogus Out-of-bounds accessCaolán McNamara
Change-Id: I6febe3d48fc9018b373a940d88d2afeefad7502c Reviewed-on: https://gerrit.libreoffice.org/80355 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-09-29constmethod for accessor-type methodsNoel Grandin
Apply the constmethod plugin, but only to accessor-type methods, e.g. IsFoo(), GetBar(), etc, where we can be sure of that constifying is a reasonable thing to do. Change-Id: Ibc97f5f359a0992dd1ce2d66f0189f8a0a43d98a Reviewed-on: https://gerrit.libreoffice.org/74269 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-09-17Better handling of non--UTF-8 filesystem pathnames in sal/osl/unx/Stephan Bergmann
The idea is to internally in sal/osl/unx/ use OString instead of OUString to represent pathnames, so that the OString carries the actual bytes that make up the pathname. At the boundary of translating between pathname OStrings and file URL OUStrings, translate sequences of bytes that are valid according to osl_getThreadTextEncoding() into UTF-8 and translate other bytes into individual (percent-encoded) bytes in the file URL. This change required duplicating some of the internal functionality in sal/osl/unx/ for both OString and OUString, and to make part of sal/rtl/uri.cxx accessible from sal/osl/unx/ via new sal/inc/uri_internal.hxx. Change-Id: Id1ebaebe9e7f2d21f350f6b1a07849edee54331f Reviewed-on: https://gerrit.libreoffice.org/78798 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-09-16Simplify forced memory readsStephan Bergmann
Change-Id: I68ea0a46bcaaadb455f2f2cc6e53950e2f26a763 Reviewed-on: https://gerrit.libreoffice.org/79003 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-09-16-Werror=volatile (GCC 10 trunk)Stephan Bergmann
"error: compound assignment with ‘volatile’-qualified left operand is deprecated" in C++20 mode Change-Id: I62825237a2f4caf359f5f116ab4097ae6b9376e6 Reviewed-on: https://gerrit.libreoffice.org/78975 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-09-10Fix typosAndrea Gelmini
Change-Id: I79f87f033eeb67d1750bb595d311d74ef3db6ce9 Reviewed-on: https://gerrit.libreoffice.org/78795 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Jenkins
2019-09-10tdf#127069 sal: preserve gid of files in the unx osl_replaceFile()Miklos Vajna
The w32 implementation preserves all attributes of the destination file, the unx one preserved none of them. Bring the unx osl_replaceFile() closer to the w32 by preserving the gid of the destination file as a start. [ No testcase, we support building on systems where the user is part of a single group only, and it's not possible to verify the effect of this change in such environments. ] Change-Id: I722d4802df34caf71a9dc0db1a3df8b76acb9de6 Reviewed-on: https://gerrit.libreoffice.org/78789 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2019-09-05Clean up {osl_,osl::}systemPathEnsureSeparator comboStephan Bergmann
Change-Id: Iafa953725c1ca8e6f3032945dc0700ae989519b9 Reviewed-on: https://gerrit.libreoffice.org/78671 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-09-05Clean up {osl_,osl::}systemPathMakeAbsolutePath comboStephan Bergmann
Change-Id: Iec4c2ff8c8239069f95fff195c49fac9f7c865d4 Reviewed-on: https://gerrit.libreoffice.org/78656 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-09-05Use OUString in osl_getNextDirectoryItemStephan Bergmann
Change-Id: Ifa1491a1af1d3c74d84ec4d6bec79fcf7a5d6bf4 Reviewed-on: https://gerrit.libreoffice.org/78653 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-09-05Fix osl_systemPathEnsureSeparator preconditionStephan Bergmann
Change-Id: I0165a14f159a6c2c7bce84d1ca646435146d1da0 Reviewed-on: https://gerrit.libreoffice.org/78643 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-09-05Let osl_systemPathEnsureSeparator directly take an OUStringStephan Bergmann
Change-Id: Ia9505298fe92d62d716e2c28ac0a5098c4b61121 Reviewed-on: https://gerrit.libreoffice.org/78642 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-09-01Resolves: ofz#16898 Direct-leak in rtl_uString_ImplAllocCaolán McNamara
Change-Id: I7bc11108790f8d87396bad3a2c5c2280f8f7d59a Reviewed-on: https://gerrit.libreoffice.org/78369 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-08-30Extract common code from #if/#else blocksStephan Bergmann
Change-Id: I7d14fd76ec4e571d5971131b5ee16f4dfe648b23 Reviewed-on: https://gerrit.libreoffice.org/78316 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-30Replace is_soffice_Impl hack with a better(?) hackStephan Bergmann
...that involves adding a second, one-off special meaning to the existing sal_detail_initialize function. This at least gets rid of the "osl_getExecutableFile contains 'soffice' substring" guesswork (and of the osl_systemPathGetFileNameOrLastDirectoryPart call there, which is what I'm actually after, for a different change to come). Change-Id: I4dd6eef1fd0411bf66943ffea415876c92d08526 Reviewed-on: https://gerrit.libreoffice.org/78291 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-30Clean up some osl::X, X_u function combosStephan Bergmann
(adapting call sites where necessary) Change-Id: Ib9ad1122571b1c00ebbb4638f94eb5698b18a1a7 Reviewed-on: https://gerrit.libreoffice.org/78289 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-29Make oslDirectoryImpl a bit more C++yStephan Bergmann
Change-Id: Iff5e26369889345d1f907e52d86eff6b89c63e20 Reviewed-on: https://gerrit.libreoffice.org/78260 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-24loplugin:returnconstval in sal..scNoel Grandin
Change-Id: I300d14d580d450ec338129918955651b9d40d5d2 Reviewed-on: https://gerrit.libreoffice.org/78059 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-08-13Avoid non-async-signal-safe functionality after forkStephan Bergmann
Triggering those SAL_WARN sporadically caused deadlocks at least for <https://ci.libreoffice.org/job/lo_ubsan/>. Change-Id: I7b7037e411c29eea26e63f71a5679127b084f447 Reviewed-on: https://gerrit.libreoffice.org/77374 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-12Avoid non-async-signal-safe functionality between fork and execStephan Bergmann
This is a partial revert of 17642437fe0d68cf868ab430f04b4fdc12f1767f "reduce ifdef forest". The original code used unsetenv only for certain platforms, and putenv for others, but code a few lines further down uses unsetenv unconditionally, so assume that it is safe to use on all relevant platforms these days. unsetenv isn't listed as async-signal-safe at <http://pubs.opengroup.org/ onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03> "Signal Actions" (but is already used a few lines further down, also between fork and exec), but at least we get rid of the memory management involved in the OUString instance. Change-Id: Iac993db8819d40a0841c455ed04ff9ca2ee2e4eb Reviewed-on: https://gerrit.libreoffice.org/77368 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-10loplugin:stringconstant (macOS)Stephan Bergmann
Change-Id: Icb9d9e1cd21e2506e36fe40a3b93b6a2521a868c Reviewed-on: https://gerrit.libreoffice.org/77239 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-08-10aTime.tm_wday gets overwritten anywayCaolán McNamara
so drop the first write in favor of the second Change-Id: Iac906d806a66e010e8352139b555aef6078bda02 Reviewed-on: https://gerrit.libreoffice.org/77235 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-08-02Fix typosAndrea Gelmini
Change-Id: Ie183c445bf8a545f59aac7b0e29f72ab679a6cf3 Reviewed-on: https://gerrit.libreoffice.org/76852 Tested-by: Jenkins Reviewed-by: Andrea Gelmini <andrea.gelmini@gelma.net>
2019-07-31Improved loplugin:stringconstant (now that GCC 7 supports it): salStephan Bergmann
Change-Id: Id9d994343d10b5d5e852b10946c036dfbeb66d04 Reviewed-on: https://gerrit.libreoffice.org/76656 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-07-24Fix typoAndrea Gelmini
"an URI", to complete: https://gerrit.libreoffice.org/#/c/75985/ Change-Id: I57489b05117fd12ae6aa22544437ab5bc6b5154f Reviewed-on: https://gerrit.libreoffice.org/76037 Tested-by: Jenkins Reviewed-by: Andrea Gelmini <andrea.gelmini@gelma.net>
2019-07-19cid#1448293 Copy into fixed size bufferCaolán McNamara
Change-Id: I0ff36c58bf2448bdccc239582ba24b69c7431c6d Reviewed-on: https://gerrit.libreoffice.org/75921 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-07-19coverity concurrency annotation attemptNoel Grandin
Let us see what happens if we annotate our mutex code, https://scan.coverity.com/models Change-Id: I7baf44d1a252f19b4ae47f3a6b318f7ccd9629d7 Reviewed-on: https://gerrit.libreoffice.org/75851 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-07-18cid#1448288 Unchecked return value from libraryCaolán McNamara
Change-Id: Id1b8044126e65e67b2496cf7a4eb86b54ba6c1df Reviewed-on: https://gerrit.libreoffice.org/75872 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-06-03tdf#67538 XTypeDetection::queryTypeByDescriptor poor performance, part4Noel Grandin
WPXSvInputStreamImpl was hammering on getFilePos pretty hard, and getFilePos uses a mutex, which is slow when it is called from every single read. So switch to using std::atomic to access position. This is specifically fixing the performance of queryTypeByDescriptor when called from a basic macro on a local test file. This takes my test macro from 8s to 4s. Change-Id: Iab707a374359e2ee0e92425b2d9a903d67cb53d4 Reviewed-on: https://gerrit.libreoffice.org/73377 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-05-16Use hand-crafted passwd entry for iOS Simulator as getpwuid_r() does not workTor Lillqvist
getpwuid_r() returns nullptr. Oddly enough, it does work on actual iOS, though. So use hand-crafted values that match behaviour on actual iOS. Change-Id: Idcc95d330a93495938520229e039f340876c3653
2019-04-18Don't set locale env vars on macOSStephan Bergmann
macosx_getLocale (via getProcessLocale, both sal/osl/unx/osxlocale.cxx) obtains from the system a locale string like "en-DE". (Whether that is even a sane and recommended way to obtain the system locale on macOS I don't know; but lets leave it at that for now.) However, setting a locale env var (LANG, LC_ALL) to such a value causes a constructor call std::locale("") to throw a std::runtime_error "collate_byname<char>::collate_byname failed to construct for ", at least on macOS 10.14.4. And libdivvun (which might be bundled with a LO extension) is known to be hit by that, see <https://github.com/divvun/libdivvun/issues/28> "locale("") gives 'collate_byname<char>::collate_byname failed to construct for ' on LO on mac". The code setting LC_ALL/LC_CTYPE/LANG was there ever since 8737d1831b48acd8a4793c4728ad8563f77b5bf8 "INTEGRATION: CWS geordi2q14: #111934#: merge CWS ooo111fix2", but for unclear reasons. Lets assume that it had no purpose (any longer). Change-Id: I0b519ad567a713d61f662aa984791db1a91c708c Reviewed-on: https://gerrit.libreoffice.org/70918 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-04-15improve loplugin simplifyconstructNoel Grandin
to find stuff like OUString s = OUString("xxx") Change-Id: Ie7ed074c1ae012734c67a2a89c564c1900a4ab04 Reviewed-on: https://gerrit.libreoffice.org/70697 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-04-13loplugin:sequentialassign in salNoel Grandin
Change-Id: I7bd1511a6acc105ab5b42c698c7578cfb9ce06b4 Reviewed-on: https://gerrit.libreoffice.org/70708 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-04-13use more std::make_uniqueNoel Grandin
Change-Id: I7d85cbc9105c5e0c4a8d9a69c4ac9d6dfc07eabd Reviewed-on: https://gerrit.libreoffice.org/70663 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-04-03In LibreOffice core commit d4d3766, several variables were changedGreg Veldman
to be declared as const. However, on platforms not excluded by NO_PTHREAD_PRIORITY, osl_thread_priority_init_Impl() then tries later to assign values to these. This leads to compiler errors on platforms so affected, including FreeBSD. Revert as necessary on affected platforms, also using NO_PTHREAD_PRIORITY to match the code in osl_thread_priority_init_Impl(). Change-Id: I0e968231e7c1be9771844222a7bab1f0fcb51a0e Reviewed-on: https://gerrit.libreoffice.org/69603 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-03-27Remove unused macros that caused compiler warnings and simplifyTor Lillqvist
Change-Id: Ica146899a5557732babf4e07b20b9e3d32426c6e Reviewed-on: https://gerrit.libreoffice.org/69824 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
2019-03-27Replace gethostbyname_r with getaddrinfoArkadiy Illarionov
The gethostbyname*() functions are obsolete. Change-Id: I14a55eba3f111a3280f23955ffd86843079c7e75 Reviewed-on: https://gerrit.libreoffice.org/69337 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-03-19hang in crashtesting, would be nice to know what failed to exec hereCaolán McNamara
#0 0x00007f8dc781e4dc in __lll_lock_wait () from /lib64/libpthread.so.0 #1 0x00007f8dc781a1b8 in _L_lock_820 () from /lib64/libpthread.so.0 #2 0x00007f8dc781a088 in pthread_mutex_lock () from /lib64/libpthread.so.0 #3 0x00007f8dc81d57d1 in lookupThreadId (hThread=140246229497600) at sal/osl/unx/thread.cxx:585 #4 0x00007f8dc81d5aa4 in osl_getThreadIdentifier (Thread=0x0) at sal/osl/unx/thread.cxx:701 #5 0x00007f8dc8173fa0 in osl::Thread::getCurrentIdentifier () at include/osl/thread.hxx:138 #6 0x00007f8dc81736ba in sal_detail_log (level=SAL_DETAIL_LOG_LEVEL_WARN, area=0x7f8dc81f2e53 "sal.osl", where=0x7f8dc81f3130 "sal/osl/unx/process.cxx:238: ", message=0x5bd5b90 "Failed to exec: ENOENT", backtraceDepth=0) at sal/osl/all/log.cxx:279 #7 0x00007f8dc816d166 in sal::detail::log (level=SAL_DETAIL_LOG_LEVEL_WARN, area=0x7f8dc81f2e53 "sal.osl", where=0x7f8dc81f3130 "sal/osl/unx/process.cxx:238: ", stream=..., backtraceDepth=0) at include/sal/log.hxx:50 #8 0x00007f8dc81c1ddc in ChildStatusProc (pData=0x7f8d9e302a90) at sal/osl/unx/process.cxx:238 #9 0x00007f8dc81d49a6 in osl_thread_start_Impl (pData=0x6757780) at sal/osl/unx/thread.cxx:235 #10 0x00007f8dc7817f6b in start_thread () from /lib64/libpthread.so.0 #11 0x00007f8dc7b227ed in clone () from /lib64/libc.so.6 Change-Id: I611cf907f89c7a1d8cdc3a9c42f449e8daaa2614 Reviewed-on: https://gerrit.libreoffice.org/69363 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2019-03-08new loplugin constvarsNoel Grandin
detect static variables that can be made const. Thanks to mike kaganski for suggesting this. Here I introduce a new plugin feature - using markers in nearby comments to disable the plugin for specific vars. Some of this stuff was old debugging code. I removed the stuff that was older than 5 years. Change-Id: I6ec7742a7fdadf28fd128b592fcdf6da8257585c Reviewed-on: https://gerrit.libreoffice.org/68807 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-03-06loplugin:unnecessaryparen improve member expressionNoel Grandin
Change-Id: I304621018cb1e2a47e478e86df4229bcf2176741 Reviewed-on: https://gerrit.libreoffice.org/68757 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-03-05re-land "new loplugin typedefparam""Noel Grandin
This reverts commit c9bb48386bad7d2a40e6958883328145ae439cad, and adds a bunch more fixes. Change-Id: Ib584d302a73125528eba85fa1e722cb6fc41538a Reviewed-on: https://gerrit.libreoffice.org/68680 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-03-04Revert "new loplugin typedefparam"Noel Grandin
This reverts commit 9865440d217d975206a3f91612f0666312bc8fd8. This is not ready to land yet, seems like the latest update of the logic reveals a bunch more places I need to fix before it can land.