daemon: Suppress two false positives from Coverity.

Using // coverity[...] or /* coverity[...] */ comments in the source
it is possible to suppress specific Coverity errors.  The suppressed
error should occur in the line following the comment.

In this case I have suppressed two false positives from Coverity:

(a) We deliberately assign to a NULL pointer in order to cause a
segfault, for testing how the library reacts when this happens.
Coverity flags this, but it is not an error in this case.

(b) Coverity does not model global variables (a known shortcoming).
Therefore the code 'errno = posix_memalign (...)' cannot be modelled
by Coverity, even though the code is correct.  Coverity raises a false
positive about this.

(Thanks Kamil Dudka, Coverity)
This commit is contained in:
Richard W.M. Jones
2013-01-16 11:30:07 +00:00
parent ce828c6afc
commit d4763a2e24

View File

@@ -215,6 +215,7 @@ debug_segv (const char *subcmd, size_t argc, char *const *const argv)
* to trap [...]"
*/
volatile int *ptr = NULL;
/* coverity[var_deref_op] */
*ptr = 1;
return NULL;
}
@@ -595,6 +596,7 @@ debug_qtrace (const char *subcmd, size_t argc, char *const *const argv)
/* For O_DIRECT, buffer must be aligned too (thanks Matt).
* Note posix_memalign has this strange errno behaviour.
*/
/* coverity[resource_leak] */
errno = posix_memalign (&buf, QTRACE_SIZE, QTRACE_SIZE);
if (errno != 0) {
reply_with_perror ("posix_memalign");