blob: 0090007a588f3e599c74ca584412c03a781f3111 [file] [log] [blame]
roman9cd677d2022-09-12 10:11:50 +02001#!/usr/bin/env bash
Radek Krejcicc3a1b62020-07-20 07:43:08 +02002
3RETVAL=0
4
Radek Krejci92769a72020-11-19 20:57:32 +01005# params - paths to the source files to search
6SRC="$*"
Radek Krejcicc3a1b62020-07-20 07:43:08 +02007
8# param FUNC - name of the function in compat to check
Christian Hopps6f326212021-03-23 12:37:29 -04009check_compat_func () {
Radek Krejcicc3a1b62020-07-20 07:43:08 +020010 FILES=`grep -rE "([^[:alnum:]]|^)$1\([^\)]+\)" --include=\*.{c,h} $SRC | cut -d: -f1 | uniq`
11 for f in $FILES; do
12 grep -q "#include \"compat.h\"" $f
13 if [ $? -ne 0 ]; then
14 echo "Missing #include \"compat.h\" in file $f for function $1()"
15 RETVAL=$((RETVAL+1))
16 fi
17 done
18}
19
Christian Hopps6f326212021-03-23 12:37:29 -040020check_compat_macro () {
Michal Vaskoc5a22832020-08-20 13:21:33 +020021 FILES=`grep -rE "([^[:alnum:]]|^)$1([^[:alnum:]]|$)" --include=\*.{c,h} $SRC | cut -d: -f1 | uniq`
22 for f in $FILES; do
23 grep -q "#include \"compat.h\"" $f
24 if [ $? -ne 0 ]; then
25 echo "Missing #include \"compat.h\" in file $f for macro $1"
26 RETVAL=$((RETVAL+1))
27 fi
28 done
29}
30
Michal Vasko938a3a52021-05-25 09:02:52 +020031check_compat_func vdprintf
Radek Krejcicc3a1b62020-07-20 07:43:08 +020032check_compat_func asprintf
Michal Vasko938a3a52021-05-25 09:02:52 +020033check_compat_func vasprintf
Radek Krejcicc3a1b62020-07-20 07:43:08 +020034check_compat_func getline
35check_compat_func strndup
36check_compat_func strnstr
Michal Vasko938a3a52021-05-25 09:02:52 +020037check_compat_func strdupa
38check_compat_func strchrnul
39check_compat_func get_current_dir_name
40check_compat_func pthread_mutex_timedlock
Michal Vaskoc5a22832020-08-20 13:21:33 +020041check_compat_func UNUSED
42check_compat_macro _PACKED
Radek Krejcicc3a1b62020-07-20 07:43:08 +020043
44exit $RETVAL