Add configuration for the deprecated strlwr/strupr functions with
according warning.
test/cfg/windows.cpp: Added tests for strlwr and strupr. Moved function
call that does not return (FreeLibraryAndExitThread) to the end of the
function to fix analysis that was silently aborted at that point
(reported as issue #8378).
Add formatting of the configuration files (cfg/*.cfg) if the xmllint
binary is found.
Changed windows commands and arguments to uppercase to be consinstent.
Silenced the output of commands that is not interesting.
Tested with the xmllint binaries and libraries found here:
ftp://ftp.zlatkovic.com/libxml/
There is a potential `nullPointer` dereference in symboldatabase. This PR attempts to fix this. Additionally, this could be detected by Cppcheck as well.
Here is a reduced and compilable testcase, where Cppcheck fails to detect a potential `nullPointer` dereference:
```
class Scope
{
public:
bool bar();
int *definedType;
};
int f(Scope *new_scope)
{
int ret = 1;
if (new_scope)
{
if (new_scope->bar())
{
if (!new_scope->definedType) {} // check for null
ret = *new_scope->definedType; // dereference
}
}
return ret;
}
```
The corresponding ticket on track, addressing the false negative: https://trac.cppcheck.net/ticket/8375
* posix library: Add strtok tests
In the posix library there is the same configuration for strtok but a
warning is added.
* posix.cfg: Remove redundant configuration for strtok, add comment.
* checkio: Fixed potential usage of invalid iterator.
* formatted the code.
A ticket about FN (invalidIterator1) is created at https://trac.cppcheck.net/ticket/8373
* Fixes issue with case inside switch that is not a compound statement was treated as garbage
This fixes an issue with the check for case keywords outside of switch
detection that would treat a case statement inside a switch that is not
a compound statement as garbage, but this is perfectly valid C++. This
construct is used in several libraries, i.e. Google Test.
* Tweak check and handle missing semicolon
Tweaks the check with feedback from danmar.
Handle the case where there is no semicolon and document it with a unit
test.
Implemented tests for the following windows configurations (more will
follow):
-Semaphore usage
-lstrcat function configuration
-_countof macro configuration
-Mutex usage
-Library usage (LoadLibrary, GetProcAddress, ...)
[std::]strtoimax and [std::]strtoumax:
They were nearly completely duplicates, i removed the ones with
less/missing configuration.
std::basic_string::empty:
It was found to be redundant because very likely someone forgot to
change "empty" to "clear" when copy&pasting the function names. The
empty function in all these clear functions makes no sense, and the
clear function also was missing.
std::queue::empty and std::array:empty:
They were both twice in the same function name list.
std::string::size, std::wstring::size:
They were already configured with many other size functions above.
std::basic_string::size:
This entry was twice in the same function name list directly one after
another. Very likely one of them should be the length function, which
does simply the same but was missing in the std.cfg.
By telling cppcheck about the Microsoft Windows _countof() macro it is
now able to detect out of bounds array accesses like this:
wchar_t buf[10];
for(size_t i = 0; i <= (_countof(buf)); ++i) {
buf[i] = L'\0'; // (error) Array 'buf[10]' accessed at index 10, which
is out of bounds.
}