User Activity

  • Posted a comment on discussion General Discussion on cppcheck

    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){...

  • Posted a comment on discussion General Discussion on cppcheck

    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,

  • Posted a comment on discussion General Discussion on cppcheck

    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

  • Posted a comment on discussion General Discussion on cppcheck

    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...

  • Posted a comment on discussion General Discussion on cppcheck

    Thanks a lot, I will follow it.

  • Posted a comment on discussion General Discussion on cppcheck

    Yes, you're right. Done.

  • Modified a comment on discussion General Discussion on cppcheck

    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....

  • Modified a comment on discussion General Discussion on cppcheck

    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....

View All

Personal Data

Username:
sgallou
Joined:
2005-01-31 18:46:00

Projects

This is a list of open source software projects that Sébastien Gallou is associated with:

Personal Tools