diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-06-20 19:02:29 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-06-21 11:28:40 +0200 |
| commit | a94597eb285254a85001a8453a95238f70de691d (patch) | |
| tree | 29b6de8fdfdd4d7520e1217f0313359665692430 /validation | |
| parent | 398907b40bc91b35910a1657d729c2c2d4de0f57 (diff) | |
| download | sparse-dev-a94597eb285254a85001a8453a95238f70de691d.tar.gz | |
teach sparse about __{BIG,LITTLE}_ENDIAN__
Some macros, structures definitions, ... are endianness specific.
This is generaly done with the help of some header files but these
headers often need information from the compiler via the macros
__BIG_ENDIAN__ / __LITTLE_ENDIAN__.
Without these defines, sparse's pre-processor may interpret things
differently than the compiler would do which may hide errors or
warn on code that is compiled out.
Fix this by letting sparse predefine these macros like compilers do.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Acked-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/endian-big.c | 11 | ||||
| -rw-r--r-- | validation/endian-little.c | 11 |
2 files changed, 22 insertions, 0 deletions
diff --git a/validation/endian-big.c b/validation/endian-big.c new file mode 100644 index 00000000..d535748c --- /dev/null +++ b/validation/endian-big.c @@ -0,0 +1,11 @@ +#if defined(__LITTLE_ENDIAN__) +#error "__LITTLE_ENDIAN__ defined!" +#endif +#if (__BIG_ENDIAN__ != 1) +#error "__BIG_ENDIAN__ not correctly defined!" +#endif + +/* + * check-name: endian-big.c + * check-command: sparse -mbig-endian $file + */ diff --git a/validation/endian-little.c b/validation/endian-little.c new file mode 100644 index 00000000..cc4a14f7 --- /dev/null +++ b/validation/endian-little.c @@ -0,0 +1,11 @@ +#if defined(__BIG_ENDIAN__) +#error "__BIG_ENDIAN__ defined!" +#endif +#if (__LITTLE_ENDIAN__ != 1) +#error "__LITTLE_ENDIAN__ not correctly defined!" +#endif + +/* + * check-name: endian-little.c + * check-command: sparse -mlittle-endian $file + */ |
