]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
clang-specific pragmas to suppress -Wmissing-braces.
authorSimon Tatham <anakin@pobox.com>
Sun, 5 Feb 2017 11:19:22 +0000 (11:19 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 5 Feb 2017 11:53:58 +0000 (11:53 +0000)
When I added some extra braces in commit 095072fa4 to suppress this
warning, I think in fact I did the wrong thing, because the
declaration syntax I was originally using is the Microsoft-recommended
one in spite of clang not liking it - I think MS would be within their
rights (should they feel like it) to add those missing braces in a
later version of the WinSock headers, which would make the current
warning-clean code stop compiling. So it's better to put the code back
as it was, and avoid the clang warning by using clang's
warning-suppression pragmas for just those declarations.

I've also done the same thing in winnet.c, for two initialisers of
IPv6 well-known addresses which had the same problem (but which I
didn't notice yesterday because a misjudged set of Windows version
macros had prevented me from compiling that file successfully at all).

windows/winnet.c
windows/winsecur.c

index b4ac166cd2d99710a2c655c1a98619d8e5e0b11c..d9da95ce59570f3665120000c7a9155233d720aa 100644 (file)
 #include <ws2tcpip.h>
 
 #ifndef NO_IPV6
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wmissing-braces"
+#endif
 const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
 const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
 #endif
 
 #define ipv4_is_loopback(addr) \
index cba7d60a196993a742851deb9a49373644c93b91..76dcae915d86e9398f1e06a7840b9604522869c3 100644 (file)
@@ -94,8 +94,16 @@ PSID get_user_sid(void)
 
 int getsids(char **error)
 {
-    SID_IDENTIFIER_AUTHORITY world_auth = { SECURITY_WORLD_SID_AUTHORITY };
-    SID_IDENTIFIER_AUTHORITY nt_auth = { SECURITY_NT_AUTHORITY };
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wmissing-braces"
+#endif
+    SID_IDENTIFIER_AUTHORITY world_auth = SECURITY_WORLD_SID_AUTHORITY;
+    SID_IDENTIFIER_AUTHORITY nt_auth = SECURITY_NT_AUTHORITY;
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
     int ret = FALSE;
 
     *error = NULL;