2

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;
}
TheLighthouse
  • 49
  • 1
  • 6

2 Answers2

5

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:

Scott McPeak
  • 8,803
  • 2
  • 40
  • 79
0

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!

TheLighthouse
  • 49
  • 1
  • 6
  • If my answer contains the information you wanted to know, you can [accept](https://stackoverflow.com/help/accepted-answer) it so others can easily see that the question has been answered. – Scott McPeak Oct 14 '20 at 09:38