From: VMware, Inc <> Date: Wed, 18 Sep 2013 03:35:40 +0000 (-0700) Subject: Fix AssertOnCompileFailed for GCC 4.8 (kernel 3.10+) X-Git-Tag: 2013.09.16-1328054~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a3eb34dd0ad5aa3e51d586cf1fcf310c1f4350e;p=thirdparty%2Fopen-vm-tools.git Fix AssertOnCompileFailed for GCC 4.8 (kernel 3.10+) GCC 4.8 now includes -Wunused-local-typedefs as part of -Wall. This causes it to spew a gazillion warnings when compiling our modules on 3.10+ kernels. Because it's a typedef we can't use the (void) cast trick, so we need to use attributes. This change introduces UNUSED_TYPE to vm_basic_types.h and uses it where appropriate to make the compiler happy when building our modules. Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/lib/include/vm_assert.h b/open-vm-tools/lib/include/vm_assert.h index d0980426f..734bcc88f 100644 --- a/open-vm-tools/lib/include/vm_assert.h +++ b/open-vm-tools/lib/include/vm_assert.h @@ -369,12 +369,17 @@ do { \ * The implementation uses both enum and typedef because the typedef alone is * insufficient; gcc allows arrays to be declared with non-constant expressions * (even in typedefs, where it makes no sense). + * + * NOTE: if GCC ever changes so that it ignores unused types altogether, this + * assert might not fire! We explicitly mark it as unused because GCC 4.8+ + * uses -Wunused-local-typedefs as part of -Wall, which means the typedef will + * generate a warning. */ #define ASSERT_ON_COMPILE(e) \ do { \ enum { AssertOnCompileMisused = ((e) ? 1 : -1) }; \ - typedef char AssertOnCompileFailed[AssertOnCompileMisused]; \ + UNUSED_TYPE(typedef char AssertOnCompileFailed[AssertOnCompileMisused]); \ } while (0) diff --git a/open-vm-tools/lib/include/vm_atomic.h b/open-vm-tools/lib/include/vm_atomic.h index 81ea4b6a0..6bef6301c 100644 --- a/open-vm-tools/lib/include/vm_atomic.h +++ b/open-vm-tools/lib/include/vm_atomic.h @@ -2640,6 +2640,9 @@ Atomic_TestBit64(Atomic_uint64 *var, // IN * (void *)val, we have (void *)(uintptr_t)val. * The specific problem case is the Windows ddk compiler * (as used by the SVGA driver). -- edward + * + * NOTE: See the comment in vm_assert.h for why we need UNUSED_TYPE in + * AtomicAssertOnCompile(), and why we need to be very careful doing so. */ #define MAKE_ATOMIC_TYPE(name, size, in, out, cast) \ @@ -2653,7 +2656,7 @@ Atomic_TestBit64(Atomic_uint64 *var, // IN && 8 * sizeof (out) == size \ && 8 * sizeof (cast) == size \ ? 1 : -1 }; \ - typedef char AssertOnCompileFailed[AssertOnCompileMisused]; \ + UNUSED_TYPE(typedef char AssertOnCompileFailed[AssertOnCompileMisused]);\ } \ \ \ diff --git a/open-vm-tools/lib/include/vm_basic_types.h b/open-vm-tools/lib/include/vm_basic_types.h index d2093cbc5..2f40dbdcd 100644 --- a/open-vm-tools/lib/include/vm_basic_types.h +++ b/open-vm-tools/lib/include/vm_basic_types.h @@ -835,6 +835,11 @@ typedef void * UserVA; # endif #endif +#ifndef UNUSED_TYPE +// XXX _Pragma would better but doesn't always work right now. +# define UNUSED_TYPE(_parm) UNUSED_PARAM(_parm) +#endif + #ifndef UNUSED_VARIABLE // XXX is there a better way? # define UNUSED_VARIABLE(_var) (void)_var