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

Gert Wollny gert.wollny at collabora.com
Tue Jun 5 20:10:59 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 9b02d4e..eb9f217 100644
--- a/src/vrend_formats.c
+++ b/src/vrend_formats.c
@@ -32,6 +32,21 @@
 #define RRR1_SWIZZLE { PIPE_SWIZZLE_RED, PIPE_SWIZZLE_RED, PIPE_SWIZZLE_RED, PIPE_SWIZZLE_ONE }
 #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.16.4



More information about the virglrenderer-devel mailing list