Hi all, I think I got a false positive on this code : void fct1(MyClass& object) ==> Parameter 'object' can be declared with const{ fct2(&, object);} bool fct2(std::function<void()> lambdaExpression, MyClass& object){ object.modify();}</void()> Parameter object is not const in fct2, so must not be const in fct1. The warning disappear if I switch parameters order in fct2 : void fct1(MyClass& object) ==> No more warning{ fct2(object, &);} bool fct2(MyClass& object, std::function<void()> lambdaExpression){...
Hello, CppCheck warns me (assertWithSideEffect) about this code : assert(fct()); With fct defined as follow : int fct() { return 3; } int fct() const { return 3; } It seems that CppCheck uses the non-const definition of fct. If I comment out the non-const definition, the CppCheck warning disappears. What is the right way to fix this warning ? Thanks,
Yes, absolutely, you're both right ! I look at this code many times without seeing that the increment makes inAddr not possible to be 0, so the test "inAddr != 0" if redundant. Thanks for your help, and sorry for this stupid question... Sébastien
Hello, I don't understand why this code generates a negativeIndex message with CppCheck 1.83 : void f() { std::vector<unsigned char> outLine; unsigned long outAddr = 0; unsigned long rowAddress = outAddr; unsigned int inAddr = 0; unsigned char rowData[256] = {0}; while (inAddr < 256) { // Built the data line if (inAddr % 16 == 0) { outLine.clear(); rowAddress = outAddr; } outLine.push_back(rowData[inAddr]); ++outAddr; ++inAddr; if (inAddr % 16 == 0 && inAddr != 0) <== negativeIndex on this line (see...
Thanks a lot, I will follow it.
Yes, you're right. Done.
Hello, I'm using CppCheck 1.83, and I get the variableScope message on this piece of code : auto nbOccurences = 0; auto isValid = false; std::for_each( m_recentlySeenDevices.begin(), m_recentlySeenDevices.end(), [&](std::pair<boost::posix_time::ptime, std::string> value) { if (value.second == deviceName) { ++nbOccurences; if (nbOccurences >= m_minTimesPerPeriod) isValid = true; } }); The error occurs on "nbOccurences" variable, which I don't see how to reduce scope without breaking the functionnal....
Hello, I'm using CppCheck 1.83, and I get the variableScope message on this piece of code : auto nbOccurences = 0; auto isValid = false; std::for_each( m_recentlySeenDevices.begin(), m_recentlySeenDevices.end(), [&](std::pair<boost::posix_time::ptime, std::string> value) { if (value.second == deviceName) { ++nbOccurences; if (nbOccurences >= m_minTimesPerPeriod) isValid = true; } }); The error occurs on "nbOccurences" variable, which I don't see how to reduce scope without breaking the functionnal....
Hello, I'm using CppCheck 1.83, and I get the variableScope message on this piece of code : auto nbOccurences = 0; auto isValid = false; std::for_each(m_recentlySeenDevices.begin(), m_recentlySeenDevices.end(), & { if (value.second == deviceName) { ++nbOccurences; if (nbOccurences >= m_minTimesPerPeriod) isValid = true; } }); The error occurs on "nbOccurences" variable, which I don't see how to reduce scope without breaking the functionnal. Is this a false positive ? Thanks, S. Gallou
yPluginApi
json-binding
WindowsSystemInformation
Websockets
Web development
WeatherUnderground
Using a communication port (serial, network...)
Unit Tests
Translating Yadoms
Tests on C++ code
Swig
Software design
SmsDialer
Rfxcom
Rest Engine
Python script interpreter
Plugins
Plugin supported platforms
Plugin development
OneWire
MegatecUps
How to start
How to run Yadoms
How to build from sources
Header files
FreeMobileSMS
Formatting
For Windows
For Ubuntu
For RaspberryPi
For MacOsX XCode-clang
For MacOsX Eclipse-g++
For MacOsX
For MacOsX
FakePlugin
Examples
Enums
Enhanced enumerations
Developping Yadoms
Database
Cross compile for raspberry PI
Cross compile Boost 1.55
Cross Remote Debug for Raspberry PI
Configuration
Coding tools
Coding rules
Classes
Capacities
Build on RaspberryPI
Coding rules
Classes
Build on RaspberryPI
Capacities
Capacities
Build on RaspberryPI
Classes
Capacities
Build on RaspberryPI
Home
Home
Home
Home
Build on RaspberryPI
For Windows
For Windows
For Windows
For Windows
For Windows
For Windows
Plugin MailSender
- Add hardware flush on serial port (not availa...
For Windows
Build on RaspberryPI
Build on RaspberryPI
- Change to Boost 1.60
Build on RaspberryPI
How to build from sources
Build on RaspberryPI
Build on RaspberryPI
Build on RaspberryPI
Build on RaspberryPI
Build on RaspberryPI
Build on RaspberryPI
Build on RaspberryPI
Build on RaspberryPI
Build on RaspberryPI
Build on RaspberryPI
Build on RaspberryPI
Build on RaspberryPI