Hi!
Since updating CppCheck 1.65 -> 1.68 a new error found in my code.
Below is minimalistic source to reproduce it.
If I uncomment m_nCounter definition here, error will gone.
In my real project this is an class member with m_nCounter declared in
header file.
First I assume it treats if (x) as a boolean, but declaring "bool
m_nConfig" removes error as well.
Of course I know I could write "if (m_nCounter > 0u)" and it helps, but
I prefer short way and wish to understand source of error.
Thanks in advance!
//uint m_nCounter;
uint Release() {
if (m_nCounter) {
m_nCounter--;
if (!m_nCounter) printf ("Resource is free.\n");
}
return m_nCounter;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
Since updating CppCheck 1.65 -> 1.68 a new error found in my code.
Below is minimalistic source to reproduce it.
If I uncomment m_nCounter definition here, error will gone.
In my real project this is an class member with m_nCounter declared in
header file.
First I assume it treats if (x) as a boolean, but declaring "bool
m_nConfig" removes error as well.
Of course I know I could write "if (m_nCounter > 0u)" and it helps, but
I prefer short way and wish to understand source of error.
Thanks in advance!
//uint m_nCounter;
uint Release() {
if (m_nCounter) {
m_nCounter--;
if (!m_nCounter) printf ("Resource is free.\n");
}
return m_nCounter;
}
You did not tell us what error you see. Based on my local result (oppositeInnerCondition) I've created a ticket: http://trac.cppcheck.net/ticket/6574
Yes, you are right. Thanks!
I recommend that you include the header file so the declaration is seen.