diff options
author | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2016-12-02 02:09:23 +0100 |
---|---|---|
committer | Stefan Tauner <stefan.tauner@gmx.at> | 2017-10-12 03:50:05 +0200 |
commit | 51e430392d125ad7b36ec43e1448f3235d221b39 (patch) | |
tree | be44c2f0cc049d5c822acd9bce422f35b8a94339 /platform.h | |
parent | 9fbbf55ecb991704cfbb2900ad9b41a1f7647759 (diff) | |
download | flashrom-git-stable.tar.gz |
Fix undefined behavior in some preprocessor define checksstable
Macros like the one below would produce undefined behavior when used as
expression/condition in #if preprocessor directives:
This patch replaces all such statements with a more verbose but
well-defined #if/#define x 1/#else/#define x 0/#endif
Found by clang (warning introduced in r258128), reported by Idwer.
Signed-off-by: Stefan Tauner <stefan.tauner@gmx.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'platform.h')
-rw-r--r-- | platform.h | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -25,9 +25,21 @@ #define __PLATFORM_H__ 1 // Helper defines for operating systems -#define IS_LINUX (defined(__gnu_linux__) || defined(__linux__)) -#define IS_MACOSX (defined(__APPLE__) && defined(__MACH__)) /* yes, both. */ -#define IS_WINDOWS (defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__WINDOWS__)) +#if (defined(__gnu_linux__) || defined(__linux__)) + #define IS_LINUX (1) +#else + #define IS_LINUX (0) +#endif +#if (defined(__APPLE__) && defined(__MACH__)) /* yes, both. */ + #define IS_MACOSX (1) +#else + #define IS_MACOSX (0) +#endif +#if (defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__WINDOWS__)) + #define IS_WINDOWS (1) +#else + #define IS_WINDOWS (0) +#endif // Likewise for target architectures #if defined (__i386__) || defined (__x86_64__) || defined(__amd64__) |