Commit Graph

408 Commits

Author SHA1 Message Date
Paul Fultz II 091f4bcf8d Add check for unnecessary search before insertion
This will warn for cases where searching in an associative container happens before insertion, like this:

```cpp
void f1(std::set<unsigned>& s, unsigned x) {
    if (s.find(x) == s.end()) {
        s.insert(x);
    }
}

void f2(std::map<unsigned, unsigned>& m, unsigned x) {
    if (m.find(x) == m.end()) {
        m.emplace(x, 1);
    } else {
        m[x] = 1;
    }
}
```

In the case of the map it could be written as `m[x] = 1` as it will create the key if it doesnt exist, so the extra search is not necessary.

I have this marked as `performance` as it is mostly concerning performance, but there could be a copy-paste error possibly, although I dont think thats common.
2019-05-02 11:04:23 +02:00
Daniel Marjamäki 1f68e038be Addons: Describe running addons from cppcheck in the manual 2019-04-08 21:31:38 +02:00
Sebastian b62a7fe059 manual.md: Spelling fixes (#1791)
Thanks!
2019-04-08 16:03:43 +02:00
Sebastian d8d4ca51d7
manual.md: Fix markdown lint warnings. (#1773) 2019-04-03 20:05:04 +02:00
versat 5fb23a4983 manual.md: Fix wrong code indentation. 2019-04-01 13:30:24 +02:00
versat 1c24a14f3f manual.md: Fixed missing back ticks and spaces.
When not between back ticks everything between angle brackets is
interpreted as HTML tags and not rendered.
Also fixed missing spaces after a sentence and in a code block.
2019-04-01 09:29:05 +02:00
Daniel Marjamäki 475036c4bc manual.md: describe library configuration 2019-03-17 10:28:53 +01:00
Daniel Marjamäki 5461fb64e3 manual.md: replace __MSCVER with _MSC_VER, that is more correct 2019-03-11 18:21:17 +01:00
Daniel Marjamäki 7fd34ac8a2 Manual: Add chapter about speeding up Cppcheck analysis 2019-03-11 13:11:17 +01:00
Daniel Marjamäki 996916358a manual.md: minor tweaks 2019-03-04 20:44:57 +01:00
Daniel Marjamäki f77754ba3b manual.md: Improved 'Get started' chapter. Add 'HTML Report' chapter 2019-03-04 20:33:13 +01:00
versat 973ccda733 manual.md: Copy and adapt chapter "Using your own custom .cfg file". 2019-03-04 16:11:42 +01:00
Daniel Marjamäki 97dc19b9b1 manual.md: imported info from manual.docbook 2019-03-03 17:31:02 +01:00
Daniel Marjamäki 5e85a3df6c manual.md: Add a 'Getting started' chapter 2019-03-02 14:33:14 +01:00
Daniel Marjamäki caaa4c0b98 manual.md: Add new manual file. 2019-03-02 10:08:09 +01:00
Andreas Rönnquist be6cec5ad8 Fix link to cppcheck wiki in man page (#1714) 2019-02-28 20:37:49 +01:00
PKEuS 11daabc1a8 Set version to 1.87.99/1.88 dev 2019-02-27 21:30:54 +01:00
fu7mu4 c78de5cdb5 change version number on manual-ja.docbook (#1658) 2019-02-10 16:57:48 +01:00
Daniel Marjamäki 502d5e9142 1.87: Set versions 2019-02-09 09:07:27 +01:00
Daniel Marjamäki 437800f46d CLI: Added --max-ctu-depth 2019-02-03 17:51:36 +01:00
Crayon d54017a0c4 Correct documentation and give an example (#1594) 2019-01-12 08:06:31 +01:00
Daniel Marjamäki dd62da02e4 manual: Try to clarify <podtype> documentation 2019-01-06 11:15:06 +01:00
fu7mu4 2abb3aa263 fix japanese translation typo and manual version (#1515) 2018-12-09 09:06:56 +01:00
PKEuS 886aa07ffb Set version to 1.86.99/1.87 dev 2018-12-08 11:53:37 +01:00
Daniel Marjamäki 5e527bdd08 Update version 2018-12-08 08:17:05 +01:00
fu7mu4 f3b127032a fix newline from backslash t to backslash n in manual-ja.docbook (#1443) 2018-10-21 07:05:15 +02:00
fu7mu4 ab985f624c update manual-ja.docbook (#1441) 2018-10-20 19:49:43 +02:00
fu7mu4 fdc6de2d52 fix typp on manual.docbook Newline is \n instead of \t (#1442) 2018-10-20 19:49:27 +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
Daniel Marjamäki 895772711a 1.85: Set version 2018-10-13 18:55:19 +02:00
Daniel Marjamäki 140b0b5ae9 astyle formatting
[ci skip]
2018-10-13 18:42:09 +02:00
Jes Ramsing 5328caa6fa Added documentation for --suppress-xml (#1420)
* Added documentation for --suppress-xml

* Bad copy place job "--suppress-xml" not "--suppressions-list"

* Fixed indentation to use . instead of tab
2018-10-13 18:41:12 +02:00
rikardfalkeborn 491ee577c6 Support floats in valid config (#1297)
* Add tests for invalid ranges

* Refactor loadLibErrors

This reduces the amount of code slightly and will simplify adding
more tests.

* Handle empty valid field

Before this change, the sequence <valid></valid> in a config file would
result in a segmentation fault. Now an empty field results in the error
message:

cppcheck: Failed to load library configuration file 'mycfg.cfg'. Bad attribute value '""'

* Add support for valid for floating point arguments

Previously, it was not possible to add valid ranges to floating point
arguments since it only handled integers. This made ranges not work well
for floating point arguments since arguments were cast to integers
before the ranges were handled.

Fix this by using doubles instead of integers if the argument is a float.
Add some tests for this and make sure errors are printed with enough
precision (somewhat arbitrarily chosen).

Note that it is still only possible to add integer ranges (i.e. -1:1).

* Add support for floats in configuration valid range

Now that it is possible to handle decimal arguments, there is no reason
to not allow non-integer ranges. Take care to not allow broken
configurations.

* Move check to within if-clause

* Move asin{,f,l} and acos{,f,l} input checks to config file
2018-07-15 22:47:56 +02:00
PKEuS 009287f912 Set version to 1.84.99/1.85 dev 2018-06-25 21:03:43 +02:00
Daniel Marjamäki a21c05edfe 1.84: Set versions
[ci skip]
2018-06-10 22:21:57 +02:00
Matthias Krüger 4c8bb9ac6f fix a few typos 2018-05-14 13:11:59 +02:00
Daniel Marjamäki 74b1d1deb6 manual: updated documentation for --template and --template-location 2018-04-23 13:38:15 +02:00
Daniel Marjamäki 7176632bc6 manual: Document suppressions 2018-04-11 12:50:02 +02:00
PKEuS 32a2060f14 Set version to 1.83.99/1.84 dev
Updated copyright year in version.h
2018-04-02 15:21:37 +02:00
Daniel Marjamäki b4924e59da manual: updated MISRA chapter. The rule texts cant be extracted directly from the PDF anymore. 2018-04-01 22:57:04 +02:00
Daniel Marjamäki 7260be81a6 Update version 2018-03-31 21:25:29 +02:00
Daniel Marjamäki e1c7507204 manual: fixed documentation for <location> 2018-03-28 15:14:48 +02:00
fu7mu4 428d067f19 Cppcheck_ja.ts is updated (#1099)
* update to 1.82

* update cppcheck_ja.ts
2018-02-25 13:50:03 +01:00
Daniel Marjamäki 28a44e25bc Manual: Added a chapter about misra 2018-01-21 16:43:47 +01:00
Daniel Marjamäki 2f508c0bba 1.82: Updated versions 2018-01-14 16:25:17 +01:00
Sebastian b538db60df Fixed typo 2017-12-19 11:06:26 +01:00
Sebastian a6983dd279 Manual: Fix sizeof reference to strncpy config (#1016)
Because the configuration for strncpy contained sizeof by error, the example was no longer correct.
Replaced with a reference to memccpy which uses sizeof.
2017-12-12 10:54:42 +01:00
amai2012 2f2172e1a7 #8178 Remove all references to XML version 1 2017-11-22 10:49:59 +01:00
PKEuS a29b33b833 Set version to 1.81.99/1.82 dev 2017-10-07 23:22:31 +02:00
Daniel Marjamäki cebf34e718 1.81: Set versions 2017-10-07 12:55:36 +02:00
Daniel Marjamäki 7cd920f9d4 Manual: Added a getting started chapter for the GUI 2017-08-12 23:09:13 +02:00
PKEuS 9558877458 Set version to 1.80.99/1.81 dev 2017-07-30 08:48:47 +02:00
Daniel Marjamäki baedfa6718 1.80: Set versions 2017-07-29 12:55:53 +02:00
Matthias Krüger 531278e075 manuals: remove remaining occurrences of --append 2017-05-14 12:27:44 +02:00
PKEuS fda1f67da6 Set version to 1.79.99/1.80 dev 2017-05-14 10:07:38 +02:00
Daniel Marjamäki e5e5a5e4b8 1.79: Set version 2017-05-13 11:25:16 +02:00
PKEuS 47570f5791 Set version to 1.78.99/1.79 dev 2017-04-05 11:24:26 +02:00
Daniel Marjamäki 2eda59eb72 Update version 2017-04-01 11:03:45 +02:00
PKEuS 92414b923a Library: Support variadic functions which are not a formatstr-function 2017-03-14 17:41:34 +01:00
Matt Johnson 6bf77955bd Example of ignoring multiple directories
Add documentation for showing how to ignore multiple directories.
Also highlight the fact that the -i option does not currently work in conjunction with the --project option.
2017-01-06 13:16:06 +09:00
PKEuS 8ba9ce4924 Set version to 1.77.99/1.78 dev 2017-01-01 11:58:39 +01:00
Daniel Marjamäki bf5fa90952 updated version info 2016-12-31 18:35:08 +01:00
Matthias Krüger ecc91ba914 fix a couple of issues in shell scripts found by codacy. 2016-12-25 00:43:47 +01:00
PKEuS e417e15567 Set version to 1.76.99/1.77 dev 2016-10-09 10:33:03 +02:00
Daniel Marjamäki 0afe745c94 1.76: Update version 2016-10-08 18:40:36 +02:00
Daniel Marjamäki 2d4f0980cb manual: describe new --project handling 2016-08-13 11:52:45 +02:00
Daniel Marjamäki 7966306171 manual: moved '</section>' 2016-08-06 18:58:12 +02:00
Daniel Marjamäki 2f1c80560a 1.75: Set versions 2016-08-06 11:47:27 +02:00
Daniel Marjamäki 63540bc114 manual.docbook: add <strz/> and <const/> 2016-07-30 16:23:03 +02:00
Daniel Marjamäki 4e338e952d manual.docbook: added documentation about <not-bool> and <pure> 2016-07-29 23:09:01 +02:00
Daniel Marjamäki 45a3bf6f6f manual.docbook: no changes. just reformatting. 2016-07-29 23:06:43 +02:00
PKEuS dec839ea79 Manual: Described file0 attribute in XML output and the relationship between <not-null/> and <not-uninit/> 2016-07-27 15:50:04 +02:00
PKEuS e2a04c508c Manual: Refactorized chapter about libraries
- Reordered sections
- Describe more features
2016-07-27 15:28:35 +02:00
PKEuS 321d2aeafb Set version to 1.74.99/1.75 dev 2016-06-07 19:19:58 +02:00
Daniel Marjamäki e7f1318d4b 1.74: set version 2016-06-05 18:21:33 +02:00
PKEuS 7ff90e7fae Set version to 1.73.99/1.74 dev 2016-04-22 16:55:19 +02:00
Daniel Marjamäki b6d3aefba6 1.73: Set versions 2016-04-08 20:46:59 +02:00
fu7mu4 02fcbb0ea0 use more recent document to translate 2016-02-02 23:32:11 +09:00
fu7mu4 879f8f9664 fix japanese sentense and add literal tags 2016-02-02 00:07:41 +09:00
fu7mu4 2c81789178 add short description 2016-02-01 23:35:22 +09:00
Daniel Marjamäki 094f49b1c2 Merge pull request #770 from fu7mu4/man-ja
translate manual.docbook in Japanese
2016-01-31 14:47:12 +01:00
fu7mu4 485403f07e translate manual.docbook in Japanese v 0.01 2016-01-31 20:01:51 +09:00
PKEuS f47e05b6a7 Set version to 1.72.99/1.73 dev 2016-01-10 10:10:33 +01:00
Daniel Marjamäki 890ceea3bf 1.72: Set version 2016-01-09 14:41:54 +01:00
Daniel Marjamäki 26c8c0e09d manual: Added information about platform configuration 2016-01-09 10:23:17 +01:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02:00
PKEuS 80c89e7a38 Set Version to 1.71.99/1.72 dev 2015-11-15 09:57:57 +01:00
Daniel Marjamäki 5df2f9c6cf 1.71: Set version 2015-11-14 18:57:42 +01:00
PKEuS 9bae189d9e Added description of -I to manual, improved formatting. 2015-09-09 15:23:42 +02:00
Philipp Kloke 687bde8af5 Set version to 1.70.99/1.71 dev 2015-09-04 21:10:05 +02:00
Daniel Marjamäki dafba604ff 1.70: Set versions 2015-09-04 19:36:34 +02:00
Daniel Marjamäki 9fedeb5b99 manual: minor tweaks 2015-07-28 14:50:51 +02:00
PKEuS 40a6941577 Warn about usage of --suppressions or --exitcode-suppressions (they are deprecated)
Removed two redundant strncmp calls
2015-07-25 17:17:52 +02:00
Daniel Marjamäki 49a9b59490 manual: rewrote the chapter about cppcheck extensions/addons 2015-06-21 15:18:24 +02:00
PKEuS 70a1e11ada Set version to 1.69.99/1.70 dev 2015-05-03 08:15:13 +02:00
Daniel Marjamäki 28985d1baa manual: Document the cwe attribute 2015-05-02 11:43:42 +02:00
Daniel Marjamäki a79791cb81 1.69: Set versions 2015-05-01 18:51:33 +02:00
Alexander Mai 9f7c71d840 Small documentation fixes 2015-04-08 21:08:18 +02:00
orbitcowboy d379ebed2d Fixed typos. No functional changes. [ci-skip] 2015-03-30 16:41:53 +02:00
Daniel Marjamäki 5d1a1b7dc8 manual: updated configuration documentation 2015-02-03 17:50:58 +01:00
Daniel Marjamäki e0b77a975f Manual: Tweaked the cfg documentation 2015-01-31 11:20:36 +01:00
PKEuS 016e89e422 Refactorizations:
- Disabled some parts of setVarId() for C code.
- Fixed mistake in <contaier> documentation
2015-01-04 10:52:11 +01:00
PKEuS e39729ffcc Library: Add <container> tag to Libraries, provide configuration for std::vector, std::deque, std::array and STL strings
Token: Added function to jump to the next template argument
2015-01-03 22:18:33 +01:00
PKEuS 9e46aabc03 Set version to 1.68.99/1.69 dev 2015-01-03 17:44:47 +01:00
Daniel Marjamäki 6793e96458 1.68: Set versions 2015-01-03 13:20:01 +01:00
Daniel Marjamäki ff11ba9847 Updated copyright year to 2015 2015-01-03 12:14:58 +01:00
PKEuS fafcf40ee6 Set version to 1.67.99/"1.68 dev" in the remaining places 2014-11-13 21:54:34 +01:00
PKEuS 6c1bb76599 Improved documentation of .cfg files. 2014-10-29 11:35:47 +01:00
Daniel Marjamäki de88c10e6b 1.67: set version 2014-10-18 11:35:00 +02:00
PKEuS 5eeb1dea91 document use of <pattern><![CDATA[...]]></pattern> (#5551) 2014-09-29 20:13:39 +02:00
PKEuS 798b845ce1 Added <use-retval/> to manual.docbook 2014-09-28 22:21:05 +02:00
PKEuS 6d5603af45 Increased version to 1.66.99/1.67 dev 2014-08-02 18:07:01 +02:00
Daniel Marjamäki 1c8c26a488 1.66: Set version 2014-08-02 11:58:30 +02:00
Daniel Marjamäki 851f89d15f manual: add chapter about writing cppcheck extensions with python 2014-07-18 19:17:32 +02:00
Daniel Marjamäki d3dbfad131 GUI, manual: some clarifications how custom user .cfg files are used (Ticket: #5847) 2014-05-25 13:24:07 +02:00
PKEuS 59418e605f Increased version number to 1.65.99/1.66 dev. 2014-05-10 12:57:33 +02:00
Daniel Marjamäki c0131eea9e 1.65: Set version 2014-05-10 12:02:06 +02:00
Reijo Tomperi 806daf7644 Add a few missing options to the man page source file. 2014-04-26 01:14:27 +03:00
PKEuS 3e6423f92b Updated manual according to #5087 2014-03-26 12:24:29 +01:00
Alexander Mai 1d4839b8a6 Fixed #1374 (false negative: using uninitialized variable in printf) 2014-03-06 06:16:14 +01:00
Daniel Marjamäki bcd230d90d Merge pull request #251 from matthiaskrgr/copyright
man, htdocs, gui, test, tools: bump a few more copyrights to 2014
2014-03-04 05:44:50 +01:00
PKEuS 470f1579c1 Incremented version to 1.65dev/1.64.99 2014-03-03 15:07:54 +01:00
Matthias Krüger a9df4a3288 man, htdocs, gui, test, tools: bump a few more copyrights to 2014 2014-03-03 11:03:17 +01:00
Daniel Marjamäki 4842115a56 1.64 : Update versions 2014-03-02 09:55:39 +01:00
PKEuS 55f68535b2 Set version to "1.64 dev"/1.63.99. Use version.h in cppcheck.cpp. 2014-01-04 10:41:13 +01:00
Daniel Marjamäki 6515691a47 1.63: Set version numbers 2014-01-04 09:32:37 +01:00
Daniel Marjamäki 8ad33273c8 manual: document <formatstring> and <valid> 2013-12-23 19:12:06 +01:00
Daniel Marjamäki 56ff1269d4 manual: Improved chapter about library configurations 2013-12-12 19:49:39 +01:00
PKEuS 4cd2fad2bf Set version to 1.63 dev 2013-10-13 09:53:56 +02:00
Daniel Marjamäki 21c537e8d7 1.62: Set versions 2013-10-12 12:22:52 +02:00
Daniel Marjamäki 33e69df6ae Fixed #5066 (buildman.sh fails) 2013-10-06 07:11:12 +02:00
PKEuS 219f6546d3 Set version to 1.62 dev 2013-08-03 19:54:39 +02:00
Daniel Marjamäki 2f7fba2087 1.61: Set versions 2013-08-03 08:04:38 +02:00
Daniel Marjamäki 8aa99e8c54 manual: fixed docbook syntax errors 2013-07-23 08:04:32 +02:00
Daniel Marjamäki 05aa400b68 manual: document <strz> and <formatstr> 2013-07-23 07:18:00 +02:00
Daniel Marjamäki 71138cffd2 manual: cleanup 2013-07-20 19:44:39 +02:00
Daniel Marjamäki be5e4ccfd5 Library: Renamed <ignore> to <leak-ignore> 2013-07-20 13:12:24 +02:00
Daniel Marjamäki a216edfd07 updated manual and CLI --help output 2013-07-20 09:38:44 +02:00
Daniel Marjamäki c071d752e0 Manual: Made chapter about library configuration shorter 2013-07-16 10:28:43 +02:00
XhmikosR 548234ba50 Trim trailing spaces. 2013-07-16 09:02:31 +02:00
Daniel Marjamäki 2a884446be Library: document not-null and not-uninit argument configuration 2013-07-15 21:58:29 +02:00
Daniel Marjamäki 66d8fa62d1 Library: added init attribute to <alloc> 2013-07-15 08:44:00 +02:00
Daniel Marjamäki 16d0a818c9 manual: describe rules and library configuration 2013-07-14 16:41:20 +02:00
Alexander Mai b7bb16ea77 Fixed #4897 (callStackToString is not available when using custom message template) 2013-07-08 06:44:25 +02:00
Daniel Marjamäki 00909486ab unusedFunction: updated help text and manual. it is recommended that this check is only enabled when the whole program is scanned. 2013-06-16 11:57:02 +02:00
Daniel Marjamäki c65437c74c manual, help text: updates of --enable text. updates of 'Preprocessor configurations' section, the --force and --max-configs can be used together with -D. 2013-06-09 10:34:45 +02:00
PKEuS ffb5317c61 Set version to 1.61 dev 2013-06-02 15:40:51 +02:00
Daniel Marjamki c83bd7f00f 1.60.1: Set versions 2013-06-02 13:13:40 +02:00
Daniel Marjamäki d36d3d5469 1.60: set version 2013-06-01 15:17:07 +02:00
PKEuS b180e92b4c Set version to 1.60 dev
Use WiX 3.7
2013-03-30 19:04:01 +01:00