[PATCH:libXau 2/2] Tell clang to shut up about the padding in struct xauth

Alan Coopersmith alan.coopersmith at oracle.com
Sun Dec 16 15:53:46 PST 2012


We can't clean it up without breaking ABI, so disable the warnings for it:

./include/X11/Xauth.h:33:19: warning: padding struct 'struct xauth' with 4 bytes to align 'address' [-Wpadded]
    char            *address;
                     ^
./include/X11/Xauth.h:35:19: warning: padding struct 'struct xauth' with 6 bytes to align 'number' [-Wpadded]
    char            *number;
                     ^
./include/X11/Xauth.h:37:19: warning: padding struct 'struct xauth' with 6 bytes to align 'name' [-Wpadded]
    char            *name;
                     ^
./include/X11/Xauth.h:39:18: warning: padding struct 'struct xauth' with 6 bytes to align 'data' [-Wpadded]
    char            *data;
                     ^

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 include/X11/Xauth.h |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/X11/Xauth.h b/include/X11/Xauth.h
index f57a1b3..a707bed 100644
--- a/include/X11/Xauth.h
+++ b/include/X11/Xauth.h
@@ -27,6 +27,14 @@ in this Software without prior written authorization from The Open Group.
 #ifndef _Xauth_h
 #define _Xauth_h
 
+/* struct xauth is full of implicit padding to properly align the pointers
+   after the length fields.   We can't clean that up without breaking ABI,
+   so tell clang not to bother complaining about it. */
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpadded"
+#endif
+
 typedef struct xauth {
     unsigned short   family;
     unsigned short   address_length;
@@ -39,6 +47,10 @@ typedef struct xauth {
     char   	    *data;
 } Xauth;
 
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
 #ifndef _XAUTH_STRUCT_ONLY
 
 # include   <X11/Xfuncproto.h>
-- 
1.7.9.2



More information about the xorg-devel mailing list