summaryrefslogtreecommitdiff
path: root/sal
AgeCommit message (Collapse)Author
2019-01-30loplugin:redundantinline (clang-cl)Stephan Bergmann
Change-Id: Ib6320ddc049e93cca4c5931ad28d1873d34bd8b4 Reviewed-on: https://gerrit.libreoffice.org/67137 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-23rhbz#1667364 Open doc as R/O for which open(...,O_RDWR) returns EOPNOTSUPPStephan Bergmann
Map that EOPNOTSUPP to osl_File_E_NOSYS (and intercept it in StillReadWriteInteraction, as used by MediaDescriptor::impl_openStreamWithURL in unotools/source/misc/mediadescriptor.cxx, which will retry opening it read-only then), instead of to osl_File_E_invalidError (which lead to the "General input/output error" box). Instead of "silently" opening the doc as read-only, this still pops up a box claiming that the doc is locked by somebody else, asking whether to open it read-only or to open a copy. That's probably because of the rDescriptor.erase( utl::MediaDescriptor::PROP_READONLY() ); in TypeDetection::impl_openStream (filter/source/config/cache/typedetection.cxx) where the comment already hints at the confusion among the different read-only and locking concepts. Changing that looks like it would easily cause regressions, so is left for a follow-up commit. (And ultimately LO wouldn't need to treat the doc as read-only at all; it would just need to not attempt to open it O_RDWR upfront, and save it via copy+rename, like other apps appear to commonly do.) Change-Id: I56e18f1864084ba222acaf0e38a604082edaf4c6 Reviewed-on: https://gerrit.libreoffice.org/66805 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-17Fix rtl_DoubleLocking::getValue_002 testStephan Bergmann
At least <https://ci.libreoffice.org//job/lo_tb_master_win/20394/> once failed with > Value in Thread #1 is 0 > Value in Thread #2 is 5 > C:/cygwin/home/tdf/lode/jenkins/workspace/lo_tb_master_win/sal/qa/rtl/doublelock/rtl_doublelocking.cxx:202:rtl_DoubleLocking::getValue::getValue_002 > assertion failed > - Expression: nValueOK != 0 > - getValue() failed, wrong value expected. and there is indeed no guarantee that either of the OGetThreads has already been through its while loop by the time the main thread calls terminate(). So make execution of the threads deterministic (and take out the sleeps that are no longer necessary, and use the now-deterministic expected values in the result checks). Change-Id: I61726906f646ffae7a21b1e08b1d973a4e51265b Reviewed-on: https://gerrit.libreoffice.org/66494 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-16Avoid unnecessary string copying in osl_getDottedInetAddrOfSocketAddrStephan Bergmann
Change-Id: I57aea80f0489c4176990d7233a4c218e5199a993 Reviewed-on: https://gerrit.libreoffice.org/66467 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-16Use OString for memory management of osl_psz_createPipeStephan Bergmann
...and make sure that the generated name is actually short enough to be stored in a sockaddr_un::sun_path. (oslPipeImpl::m_Name is only used to store such a name, to be used in osl_closePipe, so just make it of the same size to guarantee that copying between the two with strcpy will always work.) Change-Id: I6d1d0c5518e6d09eff129d682a1a334d12201e90 Reviewed-on: https://gerrit.libreoffice.org/66469 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-16Avoid unnecessary string copying in osl_getUserNameStephan Bergmann
Change-Id: I00a4b6aef307621b1607abbe75b3a64e6f8fb40a Reviewed-on: https://gerrit.libreoffice.org/66464 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-16Use OString for memory management of getBootstrapSocketPathStephan Bergmann
Change-Id: If1187cbb428d329fa10070662282d7fc3aeaf9de Reviewed-on: https://gerrit.libreoffice.org/66441 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-16New loplugin:emptyStephan Bergmann
Change-Id: I8729db064573ac21dfe6b203c5ae244d79ecc4fe Reviewed-on: https://gerrit.libreoffice.org/66430 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-16Use OString for memory management of osl_psz_getConfigDirStephan Bergmann
Change-Id: I034a0ee66266d33e294271fdcf1ab13341e51b2e Reviewed-on: https://gerrit.libreoffice.org/66426 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-16Use OString for memory management of osl_psz_getHomeDirStephan Bergmann
Change-Id: I9062c953d5fbebf323d01b05902f6cd0d0239d03 Reviewed-on: https://gerrit.libreoffice.org/66425 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-15simplify duplicate codeStephan Bergmann
Change-Id: Id3b2c0de16d2b6f7fd12dcdf6fc7354541ee0b61 Reviewed-on: https://gerrit.libreoffice.org/66396 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-15Use C++ OString/OUString classes hereStephan Bergmann
...instead of underlying C structs Change-Id: I25f1de9a902e5d8ed459c9b1bfc8a8c855eefb2d Reviewed-on: https://gerrit.libreoffice.org/66394 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-01-15Avoid unnecessary string copying in osl_getUserNameStephan Bergmann
...while being careful to keep initializing *ustrName to an empty string when returning false (whether or not client code relies on that detail) Change-Id: Idd079a0b5a31b844287048dce57bf0fafcc32d1d Reviewed-on: https://gerrit.libreoffice.org/66388 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-12-15tdf#98343 follow-up: don't fail on UNC prefixesMike Kaganski
Previously, it used to use FindFirstFile on initial parts of UNC paths, and failed, failing the whole path. Change-Id: Ibc4442e28da17625676695070ed7ddba619f9082 Reviewed-on: https://gerrit.libreoffice.org/65191 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-12-14tdf#98343: ensure PathRemoveFileSpec does not remove UNC's "\\"Mike Kaganski
PathRemoveFileSpec is used exclusively in GetCaseCorrectPathName(Ex). The GetCaseCorrectPathName function is only called for absolute or relative paths, not some arbitrary that chunks. So initial double backslashes are only possible for UNC paths. This change fixes handling of UNC paths by the functions. Previously, the UNC path was recursively shortened until it only consisted of a single "\"; then, if bCheckExistence was requested, testing this path failed, which resulted in the whole recursion to return empty result; else when returning from the recursion, original path components were appended, but initial double backslashes were never restored. This led to transformation "\\SERVER\Path\file.ext" to "\SERVER\Path\file.ext". The GetCaseCorrectPathName itself is only used in two places: osl_getSystemPathFromFileURL_() and osl_getFileStatus(). osl_getSystemPathFromFileURL_ only calls GetCaseCorrectPathName for paths longer than 248 characters; bCheckExistence is false. In that case, the resulting wrong path (missing one initial backslash) was then processed in /* it should be an UNC path, use the according prefix */ branch, where two initial characters of it were stripped, one of which being the first character of SERVER name. So, all the following manipulations with resulting path were incorrect. This code path was the reason for the bug. osl_getFileStatus calls GetCaseCorrectPathName always; it requires to check existence. This led to 0 returned from GetCaseCorrectPathName, then osl_getFileStatus continued with copying the original string, thus ignoring the error. Change-Id: If7409afa2c0dd6dd001c79e719acbfd271a6ab72 Reviewed-on: https://gerrit.libreoffice.org/65158 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-12-08Remove obsolete SAL_FALLTHROUGH completelyStephan Bergmann
...after 7ffdd830d5fb52f2ca25aa80277d22ea6d89970b "HAVE_CPP_ATTRIBUTE_FALLTHROUGH is always true now" Change-Id: I54e5ff4e036a6bb3e5774d1c0524158aae18e937 Reviewed-on: https://gerrit.libreoffice.org/64800 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-12-05loplugin:unnecessaryparen include more assignmentsNoel Grandin
Change-Id: I9fb8366634b31230b732dd38a98f800075529714 Reviewed-on: https://gerrit.libreoffice.org/64510 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-12-04tdf#34171: check foreign lockfiles to tell who has locked documentMike Kaganski
MS Office (Word/Excel/PowerPoint) lockfiles are supported now. Note that Excel does *not* create lockfiles for pre-OOXML files. This changes osl_openFile implementation on Windows, to treat osl_File_OpenFlag_NoLock to also include FILE_SHARE_DELETE flag for CreateFileW. This is required to allow opening files created with FILE_FLAG_DELETE_ON_CLOSE flag, such as Excel's owner files. The shange should be consistent with the overall meaning of the osl_File_OpenFlag_NoLock to not impose any locking constraints to the file being opened. Change-Id: I7b99012f4bd60ab3821fb91d5166a286031b7e93 Reviewed-on: https://gerrit.libreoffice.org/64496 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-12-02-Werror,-Wc++98-compat-extra-semiStephan Bergmann
Change-Id: I15d67108b4a80a4788982ad6bea65e32fd941a35
2018-12-01tdf#39468 Translate German commentsJens Carl
Change-Id: I27e5e4604cd999d778eb84976b3bea0ef35122ee Reviewed-on: https://gerrit.libreoffice.org/64353 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
2018-12-01Unit test for leading and trailing group separator charactersEike Rathke
Change-Id: I10ff8b59ba707d5795338ff5e9037473d31337bc Reviewed-on: https://gerrit.libreoffice.org/64361 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
2018-12-01A leading or trailing group separator character is not a group separatorEike Rathke
Also a group separator character followed by a non-digit is not. Change-Id: Id57e43fe7692706c5532fb05ad394224265c2750 Reviewed-on: https://gerrit.libreoffice.org/64358 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
2018-11-29Rename Mac OS X to official name macOS in comments and documentationBartosz Kosiorek
Change-Id: I651b7f202fa52ff5f5357a11aa72c43eb7dc7f95 Reviewed-on: https://gerrit.libreoffice.org/64102 Tested-by: Jenkins Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
2018-11-29loplugin:stringconstant look for unnecessary OString constructor useNoel Grandin
and tweak the methods in check.hxx to make them more flexible when called with dc.Class(xxx ? "foo" : "bar") Change-Id: I881fe628f22121ced4d8849715d6b1c92b092da1 Reviewed-on: https://gerrit.libreoffice.org/64207 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-22improve function-local statics in salNoel Grandin
Change-Id: I0853cf13162bae44cf8a5c44a4546a73f05772d9 Reviewed-on: https://gerrit.libreoffice.org/63780 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-19Fix typosAndrea Gelmini
Change-Id: I6d51e4eb4a49a30193b904b2c7d62df1e16ea3d9 Reviewed-on: https://gerrit.libreoffice.org/63475 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2018-11-17Adapt to C++2a char_tStephan Bergmann
u8 literals incompatibly change their type (as implemented by recent Clang trunk) Change-Id: Ia4f7b91f5d86656a056303d2754981ab2093a739 Reviewed-on: https://gerrit.libreoffice.org/63494 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-11-16loplugin:buriedassign in sd..writerfilterNoel Grandin
Change-Id: I954c12d9e1c493be6ac8c7b15076077b5bff5b74 Reviewed-on: https://gerrit.libreoffice.org/62811 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-13Fix race in test codeStephan Bergmann
seen it fail at <https://ci.libreoffice.org/job/lo_tb_master_win/19591/> > Value in Thread #1 is 0 > Value in Thread #2 is 0 > C:/cygwin/home/tdf/lode/jenkins/workspace/lo_tb_master_win/sal/qa/rtl/doublelock/rtl_doublelocking.cxx:199:rtl_DoubleLocking::getValue::getValue_002 > assertion failed > - Expression: nValueOK != 0 > - getValue() failed, wrong value expected. > > rtl_DoubleLocking::getValue::getValue_002 finished in: 1267ms Change-Id: I6ac85a9ff4da8c046412add40c9447ee53ef8d7e Reviewed-on: https://gerrit.libreoffice.org/63320 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-11-11Fix typoAndrea Gelmini
Change-Id: Id2478ac637140b604cb0f7e3aa4267f02aa859c4 Reviewed-on: https://gerrit.libreoffice.org/63255 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Jenkins
2018-11-10clang-tidy: (WIP) bugprone-too-small-loop-variable findings 2Tamás Zolnai
Change-Id: I1ddf3fe0e5fad265ae14712a23469b684253079d Reviewed-on: https://gerrit.libreoffice.org/63241 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
2018-11-10tdf#120703 PVS: silence a V555Mike Kaganski
V555 The expression '(curpos - bufpos) > 0' will work as 'curpos != bufpos'. Change-Id: I432c10c9c5ecc99293ec3f03f6e1a660e1c47e28 Reviewed-on: https://gerrit.libreoffice.org/63236 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-11-10Don't bother setting LC_ALL, LC_CTYPE, and LANG on iOSTor Lillqvist
An iOS app might itself, for testing and debugging purposes, look for LANG in the environment (potentially passed to it by Xcode; the OS does not set such an environment variable). It is confusing if that then gets set during the execution of core code back to a device's default. Change-Id: I9dcf44090aed84b55fd4240bda2562026cd8dacb
2018-11-07loplugin:collapseif in framework..salNoel Grandin
Change-Id: I3068b18f5cff024a48a8f8c68d69cadad30fe4d5 Reviewed-on: https://gerrit.libreoffice.org/62953 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-04replace double-checked locking patterns with thread safe local staticsMike Kaganski
Change-Id: I1bf67196e97411aeecc13ed4f91d1088a315e323 Reviewed-on: https://gerrit.libreoffice.org/62839 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-11-03tdf#120703 PVS: V547 Expression is always true/falseMike Kaganski
Change-Id: I27bf92770431f6a1f35e1c8224c0847555a8d43f Reviewed-on: https://gerrit.libreoffice.org/62819 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-11-01gbuild: rename value OS=IOS to OS=iOSMichael Stahl
This gets rid of the horrible hack in gbuild.mk to accomodate the case-incorrect iOS platform makefiles that cannot be renamed without upsetting git on file systems that sadly lack the case sensitivity feature. Keep the macro defined to IOS though. Change-Id: I1022bfef4900da00e75fc1ccce786b20f8673234 Reviewed-on: https://gerrit.libreoffice.org/62705 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de> Reviewed-by: Tor Lillqvist <tml@collabora.com> Tested-by: Tor Lillqvist <tml@collabora.com>
2018-11-01Fix build on HaikuKacper Kasper
Change-Id: I4a21258c2405bd6e5c539ec0206e28a316c6ce13 Reviewed-on: https://gerrit.libreoffice.org/60835 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2018-10-31Translate German commentsJohnny_M
Change-Id: I94cdb753d01dfd0d5b8f78ede1819b281b840ab2 Reviewed-on: https://gerrit.libreoffice.org/62669 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
2018-10-28tdf#120703 PVS: V547 Expression is always true/falseMike Kaganski
Change-Id: Iaa1a1811b638aadfe6b06b3465a182cb675031b5 Reviewed-on: https://gerrit.libreoffice.org/62476 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-10-28tdf#120703 PVS: V547 Expression is always true/falseMike Kaganski
Change-Id: Ic92cc594979cac2edac04a085957398672a5dfcc Reviewed-on: https://gerrit.libreoffice.org/62450 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-10-27tdf#120703 (PVS): V519 The variable is assigned values twice successivelyMike Kaganski
Change-Id: I9265425a215609ef6bf4298ba39c8399f215ce27 Reviewed-on: https://gerrit.libreoffice.org/62406 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-10-24Tell the actual end result and not an intermediate one in the SAL_INFO()Tor Lillqvist
Change-Id: If896ed5b1a8daa3dc057888b858b6b0d5da18f28
2018-10-24remove more rtl::OUString and OString prefixesNoel Grandin
which seem to have snuck back in since the great rounds of removals. Change-Id: I85f7f5f4801c0b48dae8b50f51f83595b286d6a1 Reviewed-on: https://gerrit.libreoffice.org/62229 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-23dlsym() typically does not find "main" so use readlink() on /proc/self/exeTor Lillqvist
Change-Id: I37b77fbc393b743fd508b7e3330409e90c7097b9 Reviewed-on: https://gerrit.libreoffice.org/62196 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
2018-10-22Remove line commented out since 2004Tor Lillqvist
Change-Id: Icf48d2d0422dc4e757627001e4792b45208054ab
2018-10-21tdf#120703 (PVS): handle failed calloc/reallocMike Kaganski
V522 There might be dereferencing of a potential null pointer 'pProfile'. Check lines: 215, 213. V522 There might be dereferencing of a potential null pointer 'pFile'. Check lines: 1081, 1068. V701 realloc() possible leak: when realloc() fails in allocating memory, original pointer 'pProfile->m_Lines' is lost. Consider assigning realloc() to a temporary pointer. V522 There might be dereferencing of a potential null pointer 'pProfile->m_Lines'. Check lines: 1328, 1324. V701 realloc() possible leak: when realloc() fails in allocating memory, original pointer 'pProfile->m_Lines' is lost. Consider assigning realloc() to a temporary pointer. V522 There might be dereferencing of a potential null pointer 'pProfile->m_Lines'. Check lines: 1365, 1362. V701 realloc() possible leak: when realloc() fails in allocating memory, original pointer 'pSection->m_Entries' is lost. Consider assigning realloc() to a temporary pointer. V701 realloc() possible leak: when realloc() fails in allocating memory, original pointer 'pProfile->m_Sections' is lost. Consider assigning realloc() to a temporary pointer. V522 There might be dereferencing of a potential null pointer 'pProfile->m_Sections'. Check lines: 1540, 1536. Change-Id: Ib6c2c79c372120268f6101f639a3ed085534cca0 Reviewed-on: https://gerrit.libreoffice.org/62116 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-10-21tdf#120703 (PVS)Mike Kaganski
V522 There might be dereferencing of a potential null pointer 'pSecImpl'. Check lines: 81, 79. Check lines: 116, 114. Check lines: 175, 173. V522 There might be dereferencing of a potential null pointer 'pSecImpl->m_pNetResource'. Check lines: 176, 175. V701 realloc() possible leak: when realloc() fails in allocating memory, original pointer 'pInfoBuffer' is lost. Consider assigning realloc() to a temporary pointer. V724 Converting type 'BOOL' to type 'sal_Bool' can lead to a loss of high-order bits. Non-zero value can become 'FALSE'. V522 There might be dereferencing of a potential null pointer 'Ident'. Check lines: 345, 340. V614 Potentially uninitialized buffer 'Name' used. Consider checking the second actual argument of the 'rtl_uString_newFromStr' function. Change-Id: Ieadc914d0f15e9c01621f8d7b5a7f8c0778c4498 Reviewed-on: https://gerrit.libreoffice.org/62090 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2018-10-20use rtl_secureZeroMemory when we're zeroing temporaries before returningCaolán McNamara
Change-Id: I0c3efa394511e479d925f5320977d071e8301f8d Reviewed-on: https://gerrit.libreoffice.org/62002 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2018-10-19Introduce UnixErrnoString() and use it in sal/osl/unxTor Lillqvist
The UnixErrnoString() function returns the symbolic name of an errno value, like "ENOENT". For now this is local to sal/osl/unx. If it can't figure out the symbolic name, it returns it as a number followed by the cleartext description (as from strerror()) in parentheses. Rationale why to use this and not strerror(): This is intended to be used in SAL_INFO() and SAL_WARN(). Such messages are intended to be read by developers, not end-users. Developers are (or should be) familiar with symbolic errno names in code anyway. The symbolic names of errno values are (or should be) instantly recognizable as such, they all start with E and are in UPPERCASE. strerror() can be localised although in LibreOffice it apparently isn't as there allegedly aren't setlocale() calls. But, anyway, the error strings might be less familiar to a developer than the symbolc errno names that one uses when coding. When encountering an unfamiliar error string the developer might want to add special handling for that error case in the code. They would need a reverse mapping from error string to errno value, by manually searching <errno.h>, looking at the comments there, hoping the match what strerror() produces, to find the corresponding symbolic errno value. Change-Id: Idc11595d528e8432a32bf474e6791f4ea7262a1e Reviewed-on: https://gerrit.libreoffice.org/61931 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>