]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Policy: detect config.h and squid.h include problems
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 10 Nov 2010 09:50:38 +0000 (22:50 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 10 Nov 2010 09:50:38 +0000 (22:50 +1300)
We currently have a policy that config.h MUST be included first so as to
pull in the portability definitions early. It MAY be included via the
legacy squid.h at present.

This alteration to the source maintenance script validates that each .c
and .cc file in the sources includes config.h or squid.h first in its
include order. Also that each .h and .cci do not include config.h which
is a double include with enforced .c/.cc requirement.

 * an ERROR: line is produces for each violating file
 * as yet the maintenance run is not blocked so as to catch as many
   errors as possible in one run
 * detection only, as yet no code alterations are performed by this script
 * FORMAT: informative lines are silenced to make ERROR: more visible

scripts/source-maintenance.sh

index ed4a463b1e84342a82a987e633b45fe4f19a2368..65c3d496ba1598ca9806a75c6deaca7fe06fc2ba 100755 (executable)
@@ -32,7 +32,7 @@ fi
 srcformat ()
 {
 PWD=`pwd`
-echo "FORMAT: ${PWD}..."
+#echo "FORMAT: ${PWD}..."
 
 for FILENAME in `ls -1`; do
 
@@ -59,6 +59,24 @@ for FILENAME in `ls -1`; do
                fi
        fi
 
+       #
+       # REQUIRE config.h/squid.h as first #include
+       #
+       case ${FILENAME} in
+       *.c|*.cc)
+               FI=`grep "#include" ${FILENAME} | head -1`;
+               if test "${FI}" != "#include \"config.h\"" -a "${FI}" != "#include \"squid.h\"" ; then
+                       echo "ERROR: ${PWD}/${FILENAME} does not include config.h or squid.h first!"
+               fi
+               ;;
+       *.h|*.cci)
+               FI=`grep "#include \"config.h\"" ${FILENAME}`;
+               if test "x${FI}" != "x" ; then
+                       echo "ERROR: ${PWD}/${FILENAME} duplicate include of config.h"
+               fi
+               ;;
+       esac
+
        #
        # DEBUG Section list maintenance
        #