Commit Graph

352 Commits

Author SHA1 Message Date
versat 0d14bdac22 windows.cfg: Add "buffer-size" attributes, fix allocation configuration.
Memory allocated with `_aligned_*malloc*()` must be freed with
`_aligned_free*()`. Using `free()` is illegal.
See
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/aligned-malloc
for details.
Also add tests for some of the changed functions.
2019-03-22 13:11:03 +01:00
versat 7c09b0cfe0 gnu.cfg: Add "buffer-size" attribute and tests for xcalloc(). 2019-03-21 10:44:18 +01:00
versat 316475f79f std.cfg: Add "buffer-size" attribute and tests for aligned_alloc(). 2019-03-21 09:25:42 +01:00
versat 9b6b94336c gnu.cfg: Add buffer-size to xmalloc; add some __builtin_*() functions. 2019-03-19 15:24:02 +01:00
Sebastian 19e9e42dd7
Library: Enhance minsize configuration and allow simple values. (#1736)
Some POSIX and Windows functions require buffers of at least some
specific size. This is now possible to configure via for example this
minsize configuration: `<minsize type="value" value="26"/>`.
The range for valid buffer size values is 1 to LLONG_MAX
(9223372036854775807)
2019-03-17 14:22:26 +01:00
Daniel Marjamäki 87fe5c060e Refactoring of Null Pointer Checker 2019-03-16 21:21:30 +01:00
Daniel Marjamäki 34a8b2b519 Quick fix for 'make checkcfg' 2019-03-16 18:17:16 +01:00
versat 6f7612de03 boost.cfg: Add argument directions; some fixes; rearrange and document.
- Remove redundant function configurations for the same function since
it is not (yet) possible to configure overloaded functions. Instead mark
the optional arguments with `default="0"` so the configuration works
with a different number of arguments.
- Add documentation to boost.cfg (links and function declarations).
- Rearranged configurations so functions, defines, ... are together now.
- Add `direction` for function arguments where applicable.
- Add some tests to boost.cpp.
2019-03-15 11:13:08 +01:00
versat 3d02c10fde gnu.cfg: Further fixes, enhancements and adding argument directions. 2019-03-14 09:26:27 +01:00
Daniel Marjamäki cdeb91bfcc Travis: Restore the uint8_t arrays 2019-03-13 18:59:55 +01:00
Sebastian 1230357146
Library: Add initial configuration with tests for SQLite3 library. (#1737) 2019-03-13 13:57:40 +01:00
Daniel Marjamäki f9ce5b3407 Travis: quick fix for 'make checkcfg' 2019-03-13 09:30:59 +01:00
Daniel Marjamäki 27d750b3a1 Travis: Fix 'make checkcfg' 2019-03-11 13:43:15 +01:00
Daniel Marjamäki 7caa6628d5 Fix 'make checkcfg' 2019-03-09 15:41:07 +01:00
versat df73f7f355 std.cfg, windows.cfg: Move strcpy_s from windows.cfg to std.cfg.
strcpy_s belongs to the standard so it must be in std.cfg instead of
windows.cfg.
Configuration for strcpy_s has been improved and tests were added.
Found by daca@home
2019-03-05 15:33:16 +01:00
Sebastian 0934577dda
Library configuration: function argument direction fixes and enhancements (#1722)
* std.cfg: Add further argument directions (in, out, inout).

* testlibrary.cpp: Add test for function argument direction configuration.

* std.cfg: runastyle and add some more direction configurations.

* library.h: Add documentation for function argument direction enum.

* Do not use "direction" library information for pointer arguments.

Also fix further unmatched uninitvar messages in std configuration
tests.

* std.cfg: Add more argument direction configurations.

* test/cfg/std.c: Add test for argument direction configuration.

* astutils.cpp: Only ignore pointer arguments for out/inout arguments.

* library.h: Use suggested documentation for argument direction enum.
2019-03-04 22:57:40 +01:00
orbitcowboy 794d72d776 wxwidgets.cfg: Added more directions-attributes. 2019-03-04 10:26:37 +01:00
Daniel Marjamäki 5087f15035 Travis: Try to fix 'make checkcfg' 2019-03-02 19:38:11 +01:00
orbitcowboy 360823203f windows.cfg: Ensure the return value is taken into account for memory (re)-allocation functions. 2019-03-01 08:58:53 +01:00
versat f6c3749015 gtk.cfg: Add support for g_alloca() and g_newa().
References:
https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-alloca
https://github.com/GNOME/glib/blob/master/glib/galloca.h
2019-02-28 15:29:37 +01:00
Martin Ettl fe402498e1 qt.cfg: Added support for Q_DECLARE_PUBLIC()-macro. 2019-02-27 15:38:31 +01:00
Martin Ettl 17c1733b0e gnu.cfg: Added support for asprintf() and vasprintf(). There is a FN with memory leak detection regarding pointer args, which is already mentioned in #8980. A comment has been added. 2019-02-27 15:17:34 +01:00
Sebastian 61f911d39a
qt.cfg: Add Q_DECLARE_TR_FUNCTIONS() and others (#1677)
Add unknownMacro Q_DECLARE_TR_FUNCTIONS found via daca@home.
Add function QCoreApplication::translate() and macro
QT_DECLARE_DEPRECATED_TR_FUNCTIONS() the unknownMacro depends on.
Reference:
https://doc.qt.io/qt-5/qcoreapplication.html#Q_DECLARE_TR_FUNCTIONS
https://doc.qt.io/qt-5/qcoreapplication.html#translate
2019-02-26 13:39:37 +01:00
versat dc63cb9f98 gtk.cfg: Add more details for g_print() and g_printerr()
Reference:
https://developer.gnome.org/glib/stable/glib-Warnings-and-Assertions.html#g-print
2019-02-18 16:48:46 +01:00
versat 4dae640e8c gtk.cfg: Add type conversion macros
Reference:
https://developer.gnome.org/glib/stable/glib-Type-Conversion-Macros.html
daca@home found that they are missing.
2019-02-15 08:44:21 +01:00
versat ed25ae3acb gtk.cfg: Add some configurations often reported as missing by daca@home
Add two g_assert*(), g_signal_connect_data(), some g_signal_connect*() functions and macros and g_strdup_printf().
2019-02-13 15:35:46 +01:00
versat fe6ea282d3 qt.cfg: Add support for QT_TR_NOOP* and QT_TRANSLATE_NOOP* macros
Reference:
https://doc.qt.io/qt-5/i18n-source-translation.html#using-qt-tr-noop-and-qt-translate-noop-in-c
2019-02-12 10:21:56 +01:00
versat 8207e48adc qt.cfg: Add support for macros Q_LIKELY and Q_UNLIKELY
Reference:
https://doc.qt.io/qt-5/qtglobal.html#Q_LIKELY
https://doc.qt.io/qt-5/qtglobal.html#Q_UNLIKELY
2019-02-12 08:21:49 +01:00
Sebastian 2c1f97d787
qt.cfg: Add support for macros `forever` and `Q_FOREVER` (#1662)
Reference:
https://doc.qt.io/qt-5/qtglobal.html#forever
https://doc.qt.io/qt-5/qtglobal.html#Q_FOREVER
2019-02-11 16:35:01 +01:00
Sebastian 3427e61383
std.cfg: Add support for std::string::assign() (#1660)
Reference: https://en.cppreference.com/w/cpp/string/basic_string/assign
2019-02-11 13:40:36 +01:00
Sebastian 5fe7aad5e3
qt.cfg: Add configuration and tests for macro Q_NULLPTR (#1651)
Qt defines `Q_NULLPTR` with `nullptr` if it is available, otherwise with `NULL`.
Since there seems to be no (sane) way to configure it the same way in the library configuration it is just defined with `NULL`.
2019-02-07 12:27:25 +01:00
Sebastian 55ce6d2073
qt.cfg: Add support and tests for QFile::exists function (#1645)
Found by daca@home
2019-02-06 13:23:05 +01:00
versat 62b9368b3c gtk.cfg: Add configurations for g_free() and g_malloc() / g_malloc0()
Reference: https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html
daca@home found these missing function configurations among others.
Also add tests for g_malloc() and g_free().
2019-01-28 13:47:46 +01:00
Sebastian b1f68229f2
Library cfg tests: Enable all tests again, exclude regressions for now (#1626)
Use `--check-library` for all tests as it was done before.
Re-enable all tests in runtests.sh again.
The regressions where runtests.sh would fail are disabled via "FIXME"
comment in the inline suppression comment.
2019-01-25 17:03:16 +01:00
Sebastian ce96ffd433
gtk.cfg: Add internationalization macros / functions (#1623)
Found via Donate CPU / daca@home.
Reference: https://developer.gnome.org/glib/stable/glib-I18N.html
Update header comment in gtk.cfg since it is now only edited manually.
2019-01-25 13:07:48 +01:00
Daniel Marjamäki c773e6ed10 runtests.sh: uncomment the xmlstarlet checking 2019-01-23 09:40:43 +01:00
Daniel Marjamäki 87489c3ffd Try to make Travis happy 2019-01-22 18:56:12 +01:00
Daniel Marjamäki f03ce97aae unmatched suppression: fix test case 2019-01-22 18:47:52 +01:00
versat 6f62b83fe6 checkcfg: Add regression test for umatchedSuppression errors
As discussed in https://trac.cppcheck.net/ticket/8931 a regression test is added
to the test/cfg/runtests.sh script to make sure that unmatchedSuppression messages result in an Cppcheck exit code that signals a failure.
2019-01-21 20:53:13 +01:00
Sebastian aa40e374ac
test/cfg/runtests.sh: Qt test: Fix syntax check when "-fPIC" is required (#1600)
On linux systems (like travis) Qt often seems to be built with the option "reduce_relocations" which requires an application using it to specify the option "-fPIC".
2019-01-14 17:48:04 +01:00
amai2012 2adf65968b posix.cfg: improve configuration for dlsym() 2019-01-12 21:50:02 +01:00
amai2012 400c6c8e76 Improve configuration for dlopen and add suitable test 2019-01-10 21:14:37 +01:00
amai2012 97bf5de133 Add more Windows (Microsoft) macros and a few lines of related test code 2019-01-08 21:15:04 +01:00
Sebastian 0aa4910244
Boost configuration: Add macros and initial test file (#1575) 2019-01-08 20:30:21 +01:00
Sebastian 7a59949cb4 qt config test: Use pkg-config to retrieve Qt settings. (#1571)
To be able to use real Qt-Code in "test/cfg/qt.cpp" and still do a
syntax check the Qt settings are read out via pkg-config now if it is
available. This way the test now can contain Qt macros and functions and
the syntax check can still be used.
Additionally the same options as for the other tests are used now for
the Qt config tests.
Installing the package "qtbase5-dev" should be enough to enable the
syntax checks (already installed for travis tests).
2019-01-07 14:40:21 +01:00
orbitcowboy 611eb81302 Fixed checkcfg: test/cfg/std.cpp:2904:error:uninitvar:Uninitialized variable: s 2018-12-23 18:09:55 +01:00
Daniel Marjamäki e6e3987935 snprintf/g_snprintf: do not allow uninitialized target buffer 2018-12-22 20:40:47 +01:00
amai2012 0f4eac657d Make script less verbose 2018-12-19 22:18:24 +01:00
Daniel Marjamäki 9742c1e2ae make checkcfg: Try to fix inline suppressions 2018-12-14 13:51:03 +01:00
Daniel Marjamäki 0b4e08cac9 Use FwdAnalysis in UnusedVar. This is still work-in-progress. Merging to master branch so it can be tested. 2018-12-13 18:52:56 +01:00
Daniel Marjamäki b7ca9bdc8d Travis: redundantCopy is not detected at the moment 2018-11-24 12:01:10 +01:00
Daniel Marjamäki ec89c7b1b8 Travis: redundantCopy is not detected at the moment 2018-11-24 11:27:27 +01:00
orbitcowboy ef05be2600 wxwidgets.cfg: Fixed FP due to overlaoded function wxSizer::Add(). 2018-11-23 09:49:08 +01:00
Daniel Marjamäki c181d28b1a astyle formatting
[ci skip]
2018-11-23 06:47:27 +01:00
orbitcowboy 428d0147bc wxwidgets.cfg: Added support for wxSizer::Add(). 2018-11-22 14:04:22 +01:00
orbitcowboy d6c85118a7 wxwidgets.cfg: Improved support for some wxStaticText member functions. 2018-11-22 13:47:17 +01:00
orbitcowboy 2b9bdc52d7 wxwidgets.cfg: Added support for wxWindow::Close() and derived classes. 2018-11-22 13:31:09 +01:00
orbitcowboy b4aa04db41 std.cfg: Added returnValue calculation for isless(), islessgreater() etc. 2018-11-20 16:58:33 +01:00
orbitcowboy 58b3d75b62 std.cfg: Added invalidFunctionArg cfg for strchr(). 2018-11-20 08:32:54 +01:00
amai 3032ac4619 Fix compile error in test code 2018-10-28 21:36:28 +01:00
orbitcowboy b998dcb5aa gnu.cfg: Added support for '__builtin_memset'. 2018-10-27 18:25:05 +02:00
rikardfalkeborn 613dc19b68 #4241: Check for address of single character passed as string (#1381)
* #4241: Check for address of single character passed as string

Add a check that address of a single character is not passed as argument
to argument marked as strings (using strz). The check does not warn if
the address of a character with known value '\0'.

Since ValueFlow currently does not handle global constants (see #7597),
do not warn if the variable is global to avoid FPs when the address of
a global variable assigned to '\0' is passed to a function expecting a
string.

Remove comment in docs saying strz is unused.

* Change asdf to Hello world

* Add test of address to first element in string

* Add error reporting function to getErrorMessages

* Fix strings in test
2018-10-14 18:49:34 +02:00
orbitcowboy 54c5d09ed3 test:std.cpp: Removed duplicate include <csetjmp>. 2018-10-06 00:23:14 +02:00
amai 5c0fd0d5b4 Skip some test on cygwin since interface is not available 2018-09-29 16:49:12 +02:00
orbitcowboy 879803c90f gnu.cfg: Fixed FP (nullpointer) when third parameter of epoll_ctl is set to NULL. 2018-09-25 09:07:49 +02:00
Sebastian 78715d3eff
bsd.cfg: Add arc4random* functions with tests. (#1344)
Reference: https://www.freebsd.org/cgi/man.cgi?query=arc4random
2018-08-16 21:37:40 +02:00
Sebastian f862cf603f
posix.cfg: Add some pthread_mutex_* functions. (#1320)
References:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_init.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lock.html
2018-07-21 17:52:12 +02:00
Sebastian 4ef452132c
posix.cfg,gnu.cfg: Add (get|set)hostname functions. (#1315)
Reference for POSIX gethostname:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostname.html
Reference for sethostname:
http://man7.org/linux/man-pages/man2/gethostname.2.html
2018-07-18 09:40:06 +02:00
rikardfalkeborn 0e639ea7c9 runtest.sh: Bugfix cfg dir when run in test/cfg (#1311)
Commit 5cc8da2db4 introduced syntax checking of xml-files. This broke
running the file directly in the test/cfg folder since it assumed the
config files to check were located in cfg in the current working
directory. Fix this by adding a variable that holds the correct path.
2018-07-15 22:24:31 +02:00
Sebastian 5cc8da2db4
cfg/runtests.sh: Check syntax of defines in configuration files. (#1303)
travis: Add xmlstarlet package used by cfg/runtests.sh
2018-07-12 08:40:26 +02:00
orbitcowboy d10788164a windows.cfg: Added support for _locale_t 2018-06-08 14:41:56 +02:00
orbitcowboy c56033f998 test/windows.cfg: Fixed wrong test case. 2018-06-08 14:33:37 +02:00
orbitcowboy 74b18d7fd9 windows.cfg: Added support for _strncpy_s_l(). 2018-06-04 16:58:09 +02:00
orbitcowboy 55ff7c0823 test std.cfg: Updated tests for strncpy_s(). 2018-05-31 11:23:54 +02:00
orbitcowboy c7993c38b5 bsd.cfg: Added support for strlcat(). 2018-05-30 16:47:00 +02:00
orbitcowboy d412c3908f test std.cfg: Fixed introduced regression. 2018-05-30 16:30:00 +02:00
orbitcowboy 39feb150c0 std.cfg and windows.cfg: Added support for wcscat_s() and _tcscat_s(). 2018-05-30 16:25:09 +02:00
orbitcowboy ef82477d11 std.cfg: Do not take the return value of std::locale::global() into account. 2018-05-30 16:04:40 +02:00
orbitcowboy d06eb3eb8f std.cfg: Added support for strcat_s() (since C11). 2018-05-30 14:30:26 +02:00
orbitcowboy 53c53db312 windows.cfg: Added support for _mbscat_s(). 2018-05-28 21:52:44 +02:00
orbitcowboy 75e28e46c5 windows.cfg: Added support for _mbscat(). 2018-05-28 10:08:11 +02:00
orbitcowboy 5b6e6db376 test std.cfg: Added more test cases for strcat() functions. 2018-05-27 10:16:02 +02:00
orbitcowboy 3407f3e932 windows.cfg: Added test cases for CreateThread(). 2018-05-25 11:50:12 +02:00
orbitcowboy d7c8c46c10 test std.cfg: Improved testing for strcat() and wcscat(). 2018-05-25 08:36:47 +02:00
Sebastian 8b94bfaf0a
windows.cfg: Add macros SUCCEEDED() and FAILED(). (#1264)
Somehow the opposite inner condition is not detected when macros are used. I created this ticket: https://trac.cppcheck.net/ticket/8596
2018-05-24 14:52:32 +02:00
orbitcowboy 3311307227 windows.cfg: Added test cases for toupper/tolower functions. 2018-05-24 10:05:56 +02:00
Sebastian aa3722feea
windows.cfg: Add lstrlen() configuration and tests. (#1239)
Reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ms647492(v=vs.85).aspx
2018-05-17 15:43:01 +02:00
Daniel Marjamäki 21ab5c7591 Removed the generated cfg tests, these are not used. 2018-05-16 07:09:08 +02:00
Sebastian 50aa3620da
posix.cfg: Add minsize to readlink[at] function configurations (#1216) 2018-05-09 18:20:45 +02:00
Sebastian b370861bed test/cfg/std.c: Cleaning up function names and redundant tests (#1198)
Make the names of uninitvar_* functions consistent and fix typos.
Remove completely redundant functions/tests. Combine according tests if
they are not completely redundant.
2018-05-01 07:33:43 +02:00
Sebastian 6208ee4af1 std.cfg: Add asctime_s function configuration with tests (#1191)
* std.cfg: Add asctime_s function configuration with tests

* std.cfg: Remove redundant/not needed not-bool attributes.
2018-04-27 23:51:16 +02:00
Sebastian 038064436d std.cfg: Fix minsize configuration for vsprintf (#1188)
minsize with argvalue for arg 2 which is a char pointer makes no sense.
Changing it to minsize with strlen for arg 2 results in false positives
(and i think false negatives too).
In std.c a test with a valid vsprintf usage is added that would result
in a FP when minsize with strlen for arg 2 would be used.
2018-04-25 02:52:19 +02:00
orbitcowboy e76f1e70e8 Added tests for invalidFunctionArg. 2018-04-23 12:54:49 +02:00
Sebastian b53c4b2032 std.cfg: Add std::vector function configurations and tests (#1180) 2018-04-19 16:41:25 +02:00
Sebastian a36dad918a std.cfg: Add std::make_pair() (#1165) 2018-04-11 19:16:55 +02:00
orbitcowboy ef62207ada std.cfg: Added more tests for some std::vector functions. 2018-04-11 17:21:26 +02:00
Sebastian 3fc53eb122 std.cfg: Add std::[w]string::compare() with tests (#1162) 2018-04-10 21:07:39 +02:00
orbitcowboy 270635eb1f wxwidgets.cfg: Improved support for wxString to number conversion functions. 2018-04-07 20:27:02 +02:00
orbitcowboy 6e21d5ab84 wxwidgets.cfg: Added support for wxAtoi, wxAtol and wxAtof. 2018-04-04 21:29:55 +02:00
orbitcowboy e3977f7e51 Formatted test/cfg files and updated 'runastyle' script. The generated test files are exclued, since they are not style-compliant. 2018-03-31 13:49:47 +02:00