aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/verify_endian_header.sh
blob: 9dcbc0ecfacca596e60c34a58f8ee21448d0ce6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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