linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* missing #includes?
@ 2003-04-26  6:51 Randy.Dunlap
  2003-04-26 20:17 ` Thunder Anklin
  2003-04-26 20:31 ` Jörn Engel
  0 siblings, 2 replies; 5+ messages in thread
From: Randy.Dunlap @ 2003-04-26  6:51 UTC (permalink / raw)
  To: lkml

[-- Attachment #1: Type: text/plain, Size: 3241 bytes --]

Hi,

I wrote a trivial bash script to check if <sourcefiles> #include
<headerfile> when <symbol> is used.   Run it at top of kernel tree,
like so:

$ check-header  STACK_MAGIC   linux/kernel.h
error: linux/kernel.h not found in ./arch/h8300/kernel/traps.c


What's the preferred thing to do here?  I would like to see explicit
#includes when symbols are used.  Is that what others expect also?

However, it makes for quite a large list of missing includes.

-- 
~Randy


Here are 2 more examples.

$ check-header  KERN_EMERG    linux/kernel.h
error: linux/kernel.h not found in ./arch/ppc64/kernel/ras.c
error: linux/kernel.h not found in ./drivers/s390/cio/device_fsm.c
error: linux/kernel.h not found in ./drivers/s390/block/dasd_3990_erp.c
error: linux/kernel.h not found in ./drivers/s390/s390mach.c
error: linux/kernel.h not found in ./drivers/char/watchdog/pcwd.c
error: linux/kernel.h not found in ./drivers/char/agp/intel-agp.c
error: linux/kernel.h not found in ./drivers/base/power.c
error: linux/kernel.h not found in ./drivers/net/oaknet.c
error: linux/kernel.h not found in ./fs/reiserfs/prints.c
error: linux/kernel.h not found in ./fs/ext3/inode.c
error: linux/kernel.h not found in ./fs/jbd/journal.c
error: linux/kernel.h not found in ./fs/jbd/transaction.c
error: linux/kernel.h not found in ./kernel/sys.c
error: linux/kernel.h not found in ./kernel/panic.c

$ check-header  NIPQUAD   linux/kernel.h
error: linux/kernel.h not found in ./net/ipv4/netfilter/ip_conntrack_core.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ip_nat_core.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ip_tables.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ip_nat_tftp.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ip_nat_rule.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ip_conntrack_standalone.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ipt_TCPMSS.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ipt_MASQUERADE.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ip_conntrack_amanda.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ip_nat_ftp.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ip_conntrack_irc.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ip_conntrack_ftp.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ipchains_core.c
error: linux/kernel.h not found in ./net/ipv4/netfilter/ipt_LOG.c
error: linux/kernel.h not found in ./net/ipv4/udp.c
error: linux/kernel.h not found in ./net/ipv4/ip_fragment.c
error: linux/kernel.h not found in ./net/ipv4/tcp_ipv4.c
error: linux/kernel.h not found in ./net/ipv4/tcp_input.c
error: linux/kernel.h not found in ./net/ipv4/ipcomp.c
error: linux/kernel.h not found in ./net/ipv4/tcp_timer.c
error: linux/kernel.h not found in ./net/core/netfilter.c
error: linux/kernel.h not found in ./net/sunrpc/svcsock.c
error: linux/kernel.h not found in ./net/bridge/netfilter/ebt_log.c
error: linux/kernel.h not found in ./net/atm/mpoa_caches.c
error: linux/kernel.h not found in ./net/sctp/protocol.c
error: linux/kernel.h not found in ./net/sctp/sm_sideeffect.c
error: linux/kernel.h not found in ./fs/afs/proc.c
error: linux/kernel.h not found in ./fs/cifs/connect.c


[-- Attachment #2: check-header --]
[-- Type: application/octet-stream, Size: 690 bytes --]

#! /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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-04-26 20:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-26  6:51 missing #includes? Randy.Dunlap
2003-04-26 20:17 ` Thunder Anklin
2003-04-26 20:36   ` Jörn Engel
2003-04-26 20:31 ` Jörn Engel
2003-04-26 20:36   ` Randy.Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).