[virglrenderer-devel] [PATCH 01/21] vrend_formats.c: Silence warning -Wmissing-field-initializers

Gert Wollny gert.wollny at collabora.com
Fri Jun 1 08:47:48 UTC 2018


The warning doesn't really add value, because the way the code is
written the fields will be initialized to zero, hence disable the warning
in this file.

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
---
 src/vrend_formats.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/vrend_formats.c b/src/vrend_formats.c
index 0be213a..9cb8f8a 100644
--- a/src/vrend_formats.c
+++ b/src/vrend_formats.c
@@ -33,6 +33,21 @@
 #define RRRG_SWIZZLE { PIPE_SWIZZLE_RED, PIPE_SWIZZLE_RED, PIPE_SWIZZLE_RED, PIPE_SWIZZLE_GREEN }
 #define RGB1_SWIZZLE { PIPE_SWIZZLE_RED, PIPE_SWIZZLE_GREEN, PIPE_SWIZZLE_BLUE, PIPE_SWIZZLE_ONE }
 
+#ifdef __GNUC__
+/* The warning missing-field-initializers is misleading: If at least one field
+ * is initialized, then the un-initialized fields will be filled with zero.
+ * Silencing the warning by manually adding the zeros that the compiler will add
+ * anyway doesn't improve the code, and initializing the files by using a named
+ * notation will make it worse, because then he remaining fields truely be
+ * un-initialized.
+ */
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wmissing-field-initializers"
+#else
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#endif
+#endif
+
 /* fill the format table */
 static struct vrend_format_table base_rgba_formats[] =
   {
-- 
2.17.0



More information about the virglrenderer-devel mailing list