#! /bin/sh
# Copyright (C) 2003 Randy Dunlap
# GPL version 2 license.
# check for files that use <symbol> from <headerfile> without #include-ing
#	the header file;
# e.g., for files that use KERN_DEBUG from <linux/kernel.h>
# or    for files that use KERNEL_VERSION from <linux/version.h>

symbol=$1
hfile=$2

if [ "$symbol" == "" ]; then
	echo "usage: check-header symbol headerfile"
	exit 1
fi
if [ "$hfile" == "" ]; then
	echo "usage: check-header symbol headerfile"
	exit 1
fi

filenames=$(find . -name \*\.c | xargs grep -l \\\<$symbol\\\>)

for file in $filenames ; do

	found=`grep -l $hfile $file`
	err=$?
	if [ $err != 0 ]; then
		echo "error: $hfile not found in $file"
	fi

done
