Re: Cppcheck: Reduction of False Positives with a MSVC Project File

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/09/18 06:31, Luke Benes wrote:
By using our MSVC Project file to teach cppcheck about includes and preprocessor configurations, I was able to reduce the number of warnings from 9,141 to 25.  You can see the Report here:

https://drive.google.com/file/d/1NCV4Zl8vcWl30f6cDfTbGwxvW7lhMxw-/view?usp=sharing

While the results are thin, are there any valid issues here?

Commenting on the referenced cppcheck_reports2/index.html:

> C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\WTypesbase.h
> 357	syntaxError		error	syntax error
> C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt\malloc.h
> 150 variableScope 398 style The scope of the variable '_Marker' can be reduced.

The above two are in system code; nothing we can do about.

> D:\cygwin\home\Hearthstone\lode\dev\core\dbaccess\win32\source\odbcconfig\odbcconfig.cxx
> 119	resourceLeak	775	error	Resource leak: hModule
> 123	resourceLeak	775	error	Resource leak: hModule

The above two should indeed be fixed

> D:\cygwin\home\Hearthstone\lode\dev\core\framework\inc\helper\shareablemutex.hxx > 73 noExplicitConstructor 398 style Class 'ShareGuard' has a constructor with 1 argument that is not explicit.

For all the nine noExplicitConstructor occurrences: For one, what puzzles me is Cppcheck's fixation on "1 argument" ctors, as "explicit" has long surpassed being only relevant for ctors that can be called with one argument; if it warns about these, why doesn't it warn about ctors taking more arguments, too? For another, for each individual ctor, they may be arguments for and against it being "explicit". Would need deeper inspection, but generally feels on the level of rather unhelpful noise.

> D:\cygwin\home\Hearthstone\lode\dev\core\framework\source\fwi\helper\shareablemutex.cxx > 33 copyCtorPointerCopying 398 style Value of pointer 'm_pMutexRef', which points to allocated memory, is copied in copy constructor instead of allocating new memory.

The above is a false positive.

> D:\cygwin\home\Hearthstone\lode\dev\core\include\osl\endian.h
> 77	preprocessorErrorDirective		error	#error undetermined endianness

The two "preprocessorErrorDirective" are apparently fallout from Cppcheck (not being called in a correct way and thus?) not being able to determine which #if branch to take.

> D:\cygwin\home\Hearthstone\lode\dev\core\include\osl\mutex.hxx
> 120 noExplicitConstructor 398 style Class 'Guard' has a constructor with 1 argument that is not explicit. > 127 noExplicitConstructor 398 style Class 'Guard' has a constructor with 1 argument that is not explicit. > 154 noExplicitConstructor 398 style Class 'ClearableGuard' has a constructor with 1 argument that is not explicit. > 161 noExplicitConstructor 398 style Class 'ClearableGuard' has a constructor with 1 argument that is not explicit. > 200 noExplicitConstructor 398 style Class 'ResettableGuard' has a constructor with 1 argument that is not explicit. > 207 noExplicitConstructor 398 style Class 'ResettableGuard' has a constructor with 1 argument that is not explicit.
> D:\cygwin\home\Hearthstone\lode\dev\core\include\rtl\byteseq.h
> 199 noExplicitConstructor 398 style Class 'ByteSequence' has a constructor with 1 argument that is not explicit. > 210 noExplicitConstructor 398 style Class 'ByteSequence' has a constructor with 1 argument that is not explicit.

(see above)

> D:\cygwin\home\Hearthstone\lode\dev\core\include\sal\alloca.h
> 60 preprocessorErrorDirective error #error "unknown platform: please check for alloca"

(see above)

> D:\cygwin\home\Hearthstone\lode\dev\core\sal\osl\w32\dllentry.cxx
> 224 ignoredReturnValue 252 warning Return value of function CreateThread() is not used. > 224 leakReturnValNotUsed 771 error Return value of allocation function 'CreateThread' is not stored.

From the comments around the above two, they appear to be intentional.

> D:\cygwin\home\Hearthstone\lode\dev\core\sal\rtl\byteseq.cxx
> 43 variableScope 398 style The scope of the variable 'nElements' can be reduced.

The above could indeed be fixed.

> 82 incorrectStringBooleanError 571 warning Conversion of string literal "### null ptr!" to bool always evaluates to true.
> D:\cygwin\home\Hearthstone\lode\dev\core\sot\source\sdstor\stgavl.cxx
> 137 incorrectStringBooleanError 571 warning Conversion of string literal "The pointer is not allowed to be NULL!" to bool always evaluates to true. > 149 incorrectStringBooleanError 571 warning Conversion of string literal "The pointer is not allowed to be NULL!" to bool always evaluates to true. > 180 incorrectStringBooleanError 571 warning Conversion of string literal "The pointer is not allowed to be NULL!" to bool always evaluates to true. > 191 incorrectStringBooleanError 571 warning Conversion of string literal "The pointer is not allowed to be NULL!" to bool always evaluates to true. > 302 incorrectStringBooleanError 571 warning Conversion of string literal "The pointers may not be NULL!" to bool always evaluates to true.

The above six are all occurrencs of the assert(X && "explanation") idiom, and as such false positives. (Odd that there are only warnings for these six occurrences; I'm pretty sure there's more across the code base. Maybe that's because "the 'LibreOffice.sln' project is incomplete and cannot yet generate full builds.")
_______________________________________________
LibreOffice mailing list
LibreOffice@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/libreoffice




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux