Coverity. Configure to ignore certain sections of the source code

4.3k Views Asked by At

Looking for a way to configure coverity to ignore certain code sections. For example let's say I have source code with func1 and func2. I don't want coverity to analyse func1, but I still want it to analyse func2. Is there a way to do that? Is there a special inline comment that I can add perhaps?

int func1(int* value)
{
   *value++;

  return 0;
}
int func2(int* value)
{
 *value--;

 return 0;
}
2

There are 2 best solutions below

0
On

You can exclude a section of C/C++ code using the __COVERITY__ preprocessor macro, which is defined by the Coverity compiler. For example, to exclude func1 but include func2 in the analysis, do something like:

#ifndef __COVERITY__           // <-- added
int func1(int* value)
{
   *value++;

  return 0;
}
#endif                         // <-- added

int func2(int* value)
{
 *value--;

 return 0;
}

Related:

1
On

Using the pre processor macro "COVERITY" works great!

Also to ignore a single line one can use the //coverity[EVENT_TAG_NAME] method as outlined in the following link

https://doclazy.wordpress.com/2011/07/14/coverity-suppressing-false-positives-with-cod/

Thanks for all the help!