checklibs.sh revision 4c713bf9401c2e55660bdcbba8d71032f482a330
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson#!/bin/sh
1da14e066c23245c255dedb311d5a9cf0e5bb667Automatic Updater#
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence#
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater# This Source Code Form is subject to the terms of the Mozilla Public
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson# License, v. 2.0. If a copy of the MPL was not distributed with this
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson# file, You can obtain one at http://mozilla.org/MPL/2.0/.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrewsstatus=0
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews#
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# Check for missing #include <isc/print.h> or "print_p.h"
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews#
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrewslist=`git grep -l snprintf lib bin |
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews grep '\.c$' |
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson grep -vE -e '(lib/bind|lib/dns/rdata|lib/dns/gen.c)' \
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson -e '(lib/isc/win32/time.c|dlzexternal/driver.c)' |
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews xargs grep -EL "(isc/print.h|print_p.h)" 2> /dev/null`
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein[ -n "$list" ] && {
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein status=1
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence echo 'Missing #include <isc/print.h> or #include "print_p.h":'
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson echo "$list"
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson}
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
a5c077e40c784cf9e25c95a1ab94db2faab04ae9Brian Wellington#
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson# Check for missing #include <isc/string.h>"
cc0a5f714231709409b9e1b85f0f97ae50854451Mark Andrews#
6028d1ce0380d0ba7f6c6ecd1ad20b31ddd1becbDavid Lawrencelist=`git grep -lw strsep lib bin |
364a82f7c25b62967678027043425201a5e5171aBob Halley grep '\.c$' |
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson grep -vE -e '(lib/bind|lib/dns/rdata|lib/dns/gen.c)' \
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence -e '(lib/isc/win32/time.c)' |
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington xargs grep -L "<isc/string.h>"`
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson[ -n "$list" ] && {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington status=1
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington echo 'Missing #include <isc/string.h>:'
5afa531442369eed0e93a8af14422b30f400bd89Mark Andrews echo "$list"
476386968b1f287a695f73c48862e961011af99bMark Andrews}
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
9259fed3d8ac5d1efa9b5a647969e40c9c934484Andreas Gustafsson#
3aca8e5bf3740bbcc3bb13dde242d7cc369abb27Mark Andrews# Check for missing #include <inttypes.h>"
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington#
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafssonlist=`git grep -l uintptr_t lib bin |
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson grep '\.c$' |
62700b67eb8abb7d13f9c3c1bc4b60a1477d35d8Mark Andrews grep -vE -e '(lib/bind|lib/dns/rdata|lib/dns/gen.c)' \
9259fed3d8ac5d1efa9b5a647969e40c9c934484Andreas Gustafsson -e '(lib/isc/win32/time.c)' |
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson xargs grep -L "<inttypes.h>"`
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein[ -n "$list" ] && {
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson status=1
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson echo 'Missing #include <inttypes.h>:'
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson echo "$list"
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson}
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson#
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson# Check for missing #include <config.h>
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson#
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafssonlist=`git ls-files -c bin lib | grep '\.c$' |
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein xargs grep -L '#include ["<]config.h[">]' |
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson grep -vE -e '(/win32/|bin/pkcs11/|lib/dns/rdata|lib/bind/)' \
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson -e '(ifiter_|lib/dns/gen.c|lib/dns/spnego_asn1.c)' \
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson -e '(lib/dns/rbtdb64.c|lib/isc/entropy.c|lib/isc/fsaccess.c)' \
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews -e '(bin/tests/virtual-time/vtwrapper.c|symtbl.c|version.c)'`
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews[ -n "$list" ] && {
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater status=1
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson echo 'Missing #include "config.h":'
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson echo "$list"
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson}
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
7b68fa6229f1edadac44c7ec459c9ed77a8368c8Mark Andrewslist=`git ls-files -c lib bin | grep '\.vcxproj\.in$' |
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews xargs grep -L '<ProjectGuid>' |
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington awk '{a[$2]++;} END { for (g in a) if (a[g] != 1) print g;}'`
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson[ -n "$list" ] && {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington status=1
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington echo 'duplicate <ProjectGuid>'"'"'s:'
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington echo "$list"
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington}
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellingtonfor lib in `git ls-files -c lib |
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews sed -n 's;^lib/\([^/]*\)/win32/.*\.def.*$;\1;p' |
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington sort -u`
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellingtondo
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington def=`git ls-files -c lib |
3eef7eaba00e9bd468d8036c709a296a0e5b76f1Andreas Gustafsson grep lib/${lib}/win32/lib${lib}.def |
7b68fa6229f1edadac44c7ec459c9ed77a8368c8Mark Andrews sort |
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington tail -n 1`
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington test -z "$def" && continue;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington test -f "$def" || continue;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dirs=
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson test -d lib/$lib/include && dirs="$dirs lib/$lib/include"
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson test -d lib/$lib/win32/include && dirs="$dirs lib/$lib/win32/include"
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson test -z "$dirs" && continue;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington pat=$lib
ad5bc22a819190839bdcc4d102d023782dc23660Mark Andrews test $lib = dns && pat='\(dns\|dst\)'
c7e266b7e5675e12d1ca3cc929f24b3e86d41f8eEvan Hunt pat="^${pat}_[a-z0-9_]*("
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington list=`git ls-files -c $dirs | grep '\.h$' |
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington xargs grep "$pat" |
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington sed -e 's/.*://' -e 's/(.*//' |
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington while read p
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington do
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson case $p in
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson isc__app_register) continue;; # internal
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein isc__mem_register) continue;; # internal
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc__task_register) continue;; # internal
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson isc__taskmgr_dispatch) continue;; # internal
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc__timer_register) continue;; # internal
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews isc_ntsecurity_getaccountgroups) continue;; # internal
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews isc__taskmgr_dispatch) continue;; # no threads
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews isc__taskmgr_ready) continue;; # no threads
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_socketmgr_getmaxsockets) p=isc__socketmgr_getmaxsockets;;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington esac
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington grep -q "^${p}"'$' $def && continue
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington test $lib = isc -a -f lib/isc/win32/libisc.def.exclude &&
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington grep -q "^${p}"'$' lib/isc/win32/libisc.def.exclude &&
a687a0592bbe3a582860eb5f03725bf80d7ac1d8Mark Andrews continue
a687a0592bbe3a582860eb5f03725bf80d7ac1d8Mark Andrews if test -d lib/$lib/win32
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington then
a687a0592bbe3a582860eb5f03725bf80d7ac1d8Mark Andrews grep -q "^$p(" lib/$lib/*.c lib/$lib/win32/*.c && echo "$p"
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington else
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington grep -q "^$p(" lib/$lib/*.c && echo "$p"
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington fi
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington done`
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington [ -n "$list" ] && {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington status=1
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington echo "Missing from ${def}:"
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington echo "$list"
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington }
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewsdone
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewsexit $status
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews