daemon: Ignore -Wnull-dereference & -Wshift-overflow warnings.

One -Wnull-dereference warning is real: we deliberately cause a
segfault in one of the tests.

There is a -Wshift-overflow bug in a Gtk 2 header.

The others are the result of shortcomings in GCC.

In all cases we have to add GCC diagnostic overrides to ignore
the warnings when compiling with ./configure --enable-werror.
This commit is contained in:
Richard W.M. Jones
2016-07-24 10:47:07 +01:00
parent d0e263248d
commit a8e15ea924
6 changed files with 32 additions and 3 deletions

View File

@@ -28,6 +28,11 @@
#include <stdio.h>
#include <string.h>
/* GCC can't work out that the YAJL_IS_<foo> test is sufficient to
* ensure that YAJL_GET_<foo> later doesn't return NULL.
*/
#pragma GCC diagnostic ignored "-Wnull-dereference"
#define Val_none (Val_int (0))
value virt_builder_yajl_tree_parse (value stringv);

View File

@@ -989,6 +989,9 @@ do_internal_rhbz914931 (int count)
return 0;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnull-dereference"
static void
deliberately_cause_a_segfault (void)
{
@@ -1001,3 +1004,5 @@ deliberately_cause_a_segfault (void)
/* coverity[var_deref_op] */
*ptr = 1;
}
#pragma GCC diagnostic pop

View File

@@ -32,6 +32,11 @@
#include "actions.h"
#include "optgroups.h"
/* GCC can't work out that the YAJL_IS_<foo> test is sufficient to
* ensure that YAJL_GET_<foo> later doesn't return NULL.
*/
#pragma GCC diagnostic ignored "-Wnull-dereference"
GUESTFSD_EXT_CMD(str_ldmtool, ldmtool);
int

View File

@@ -122,8 +122,14 @@ receive_stdout (int s)
error (EXIT_FAILURE, errno, "recvmsg stdout fd");
cmptr = CMSG_FIRSTHDR (&msg);
if (cmptr == NULL)
if (cmptr == NULL) {
error (EXIT_FAILURE, errno, "didn't receive a stdout file descriptor");
/* Makes GCC happy. error() cannot be declared as noreturn, so
* GCC doesn't know that the subsequent dereference of cmptr isn't
* reachable when cmptr is NULL.
*/
abort ();
}
if (cmptr->cmsg_len != CMSG_LEN (sizeof (int)))
error (EXIT_FAILURE, 0, "cmsg_len != CMSG_LEN (sizeof (int))");
if (cmptr->cmsg_level != SOL_SOCKET)

View File

@@ -66,8 +66,12 @@
#include <pthread.h>
#pragma GCC diagnostic ignored "-Wstrict-prototypes" /* error in <gtk.h> */
/* errors in <gtk.h> */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#pragma GCC diagnostic ignored "-Wshift-overflow"
#include <gtk/gtk.h>
#pragma GCC diagnostic pop
#include "ignore-value.h"

View File

@@ -33,8 +33,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#pragma GCC diagnostic ignored "-Wstrict-prototypes" /* error in <gtk.h> */
/* errors in <gtk.h> */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#pragma GCC diagnostic ignored "-Wshift-overflow"
#include <gtk/gtk.h>
#pragma GCC diagnostic pop
#include "ignore-value.h"
#include "p2v.h"