scripts: add a script for checking presence of <endian.h>

Change-Id: I6a1e7fc2e96f42fc596f47b4d7f1ac6c61d834b6
This commit is contained in:
Vadim Yanitskiy 2021-10-30 01:09:58 +03:00
parent 3dad8b5e7f
commit f6974d89c8
1 changed files with 23 additions and 0 deletions

23
scripts/verify_endian_header.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
# Usage: ./verify_endian_header.sh $(find . -name "*.[hc]")
HEADER="osmocom/core/endian.h"
COUNT=0
for f in $*; do
# Obviously, ignore the header file defining the macros
if [ $(basename $f) = $(basename $HEADER) ]; then
continue
fi
# Match files using either of OSMO_IS_{LITTLE,BIG}_ENDIAN
if grep -q "OSMO_IS_\(LITTLE\|BIG\)_ENDIAN" $f; then
# The header file must be included
if ! grep -q "#include <$HEADER>" $f; then
echo "File '$f' does not #include <$HEADER>"
COUNT=$((COUNT + 1))
fi
fi
done
exit $COUNT