Skip to content

Commit

Permalink
lstopo: properly disable -Wmissing-field-initializers when really needed
Browse files Browse the repository at this point in the history
Detect it on configure and #define a macro to only disable it when supported

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Feb 24, 2020
1 parent 97d3f30 commit 94e5a4f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config/hwloc.m4
Expand Up @@ -416,6 +416,9 @@ EOF])
_HWLOC_CHECK_GCC_OPTION([-Wtype-limits], [add])
_HWLOC_CHECK_GCC_OPTION([-Wstack-usage=262144], [add])
# -Wextra enables some -Wfoo that we want to disable it at some place
_HWLOC_CHECK_GCC_OPTION([-Wmissing-field-initializers], [add], [AC_DEFINE(HWLOC_HAVE_GCC_W_MISSING_FIELD_INITIALIZERS, 1, [Define to 1 if gcc -Wmissing-field-initializers is supported and enabled])])
HWLOC_CFLAGS="$HWLOC_CFLAGS $add"
fi
])
Expand Down
4 changes: 2 additions & 2 deletions utils/lstopo/lstopo-draw.c
Expand Up @@ -29,7 +29,7 @@
#define DARKER_EPOXY_G_COLOR ((DARK_EPOXY_G_COLOR * 100) / 110)
#define DARKER_EPOXY_B_COLOR ((DARK_EPOXY_B_COLOR * 100) / 110)

#ifdef __GNUC__
#ifdef HWLOC_HAVE_GCC_W_MISSING_FIELD_INITIALIZERS
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
/* each of these colors must be declared in declare_colors() */
Expand All @@ -50,7 +50,7 @@ struct lstopo_color MISC_COLOR = { 0xff, 0xff, 0xff, 0 };
struct lstopo_color PCI_DEVICE_COLOR = { DARKER_EPOXY_R_COLOR, DARKER_EPOXY_G_COLOR, DARKER_EPOXY_B_COLOR, 0 };
struct lstopo_color OS_DEVICE_COLOR = { 0xde, 0xde, 0xde, 0 };
struct lstopo_color BRIDGE_COLOR = { 0xff, 0xff, 0xff, 0 };
#ifdef __GNUC__
#ifdef HWLOC_HAVE_GCC_W_MISSING_FIELD_INITIALIZERS
#pragma GCC diagnostic warning "-Wmissing-field-initializers"
#endif

Expand Down
8 changes: 7 additions & 1 deletion utils/lstopo/lstopo-windows.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2009 CNRS
* Copyright © 2009-2019 Inria. All rights reserved.
* Copyright © 2009-2020 Inria. All rights reserved.
* Copyright © 2009-2010, 2012 Université Bordeaux
* Copyright © 2011 Cisco Systems, Inc. All rights reserved.
* See COPYING in top-level directory.
Expand Down Expand Up @@ -176,7 +176,13 @@ WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)

case WM_PAINT: {
HFONT font;
#ifdef HWLOC_HAVE_GCC_W_MISSING_FIELD_INITIALIZERS
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
struct lstopo_color white = {0xff, 0xff, 0xff};
#ifdef HWLOC_HAVE_GCC_W_MISSING_FIELD_INITIALIZERS
#pragma GCC diagnostic warning "-Wmissing-field-initializers"
#endif
BeginPaint(hwnd, &the_output.ps);
font = CreateFont(loutput->fontsize, 0, 0, 0, 0, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, NULL);
SelectObject(the_output.ps.hdc, (HGDIOBJ) font);
Expand Down

0 comments on commit 94e5a4f

Please sign in to comment.