]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Update __IS_FREE_BSD__ macro in vm_basic_defs.h
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:55 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:23:55 +0000 (11:23 -0700)
The __IS_FREEBSD__ macro in vm_basic_defs.h uses "defined" in
the definition.  That is undefined behavior and the FreeBSD default
compiler, clang (LLVM), warns about this pervasively misused
construct.  With all warnings equivalent to an error, builds fail.

The object-like macro __IS_FREEBSD__ has been rewritten in a manner
acceptable to the current C standard.

Open-vm-tools pull request: https://github.com/vmware/open-vm-tools/pull/136

open-vm-tools/AUTHORS
open-vm-tools/lib/include/vm_basic_defs.h

index 6409eb807a4ccc701a38ccf44e623e1898f7ea66..d830fe0e22177a90a34b6f4b5cce341b3f38f93b 100644 (file)
@@ -1 +1,6 @@
 The VMware Guest Components Team
+
+Contributors to open-vm-tools:
+
+Steve Wills     Correct __IS_FREEBSD__ macro in vm_basic_defs.h (clang)
+                - https://github.com/vmware/open-vm-tools/pull/136
index faca55747ce7f1ee9fe2a27c9501461523ceda0e..3c321f42313740941cbac35df2f00d24dfc7da29 100644 (file)
 #include "vm_basic_types.h" // For INLINE.
 
 /* Checks for FreeBSD, filtering out VMKERNEL. */
-#define __IS_FREEBSD__ (!defined(VMKERNEL) && defined(__FreeBSD__))
+#if !defined(VMKERNEL) && defined(__FreeBSD__)
+#define __IS_FREEBSD__ 1
+#else
+#define __IS_FREEBSD__ 0
+#endif
 #define __IS_FREEBSD_VER__(ver) (__IS_FREEBSD__ && __FreeBSD_version >= (ver))
 
 #if defined _WIN32 && defined USERLEVEL
    #include <stddef.h>  /*
-                         * We redefine offsetof macro from stddef; make 
+                         * We redefine offsetof macro from stddef; make
                          * sure that it's already defined before we do that.
                          */
    #include <windows.h>        // for Sleep() and LOWORD() etc.