mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user