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

* Re: missing #includes?
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Thunder Anklin @ 2003-04-26 20:17 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: lkml

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

Salut,

On Fri, Apr 25, 2003 at 11:51:19PM -0700, Randy.Dunlap wrote:
> 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?

It's perlable. I might do this if you want.

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

I  suppose this  is because  it's implicitly  included via  some other
include file. You will need to descend through

#include <blah>

in order to do the right checks.

			Thunder

[-- Attachment #2: Type: application/pgp-signature, Size: 187 bytes --]

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

* Re: missing #includes?
  2003-04-26  6:51 missing #includes? Randy.Dunlap
  2003-04-26 20:17 ` Thunder Anklin
@ 2003-04-26 20:31 ` Jörn Engel
  2003-04-26 20:36   ` Randy.Dunlap
  1 sibling, 1 reply; 5+ messages in thread
From: Jörn Engel @ 2003-04-26 20:31 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: lkml

On Fri, 25 April 2003 23:51:19 -0700, Randy.Dunlap wrote:
> 
> 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.

As long as it doesn't change the kernel binary, I don't have a strong
opinion. Explicit #includes are nicer, but is it worth the trouble?
Do the implicit #includes hurt anywhere? I don't know.

Jörn

-- 
Those who come seeking peace without a treaty are plotting.
-- Sun Tzu

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

* Re: missing #includes?
  2003-04-26 20:17 ` Thunder Anklin
@ 2003-04-26 20:36   ` Jörn Engel
  0 siblings, 0 replies; 5+ messages in thread
From: Jörn Engel @ 2003-04-26 20:36 UTC (permalink / raw)
  To: Thunder Anklin; +Cc: Randy.Dunlap, lkml

On Sat, 26 April 2003 22:17:07 +0200, Thunder Anklin wrote:
> On Fri, Apr 25, 2003 at 11:51:19PM -0700, Randy.Dunlap wrote:
> > 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?
> 
> It's perlable. I might do this if you want.

If you just take the current script, there is little point in a
translation. But if you could merge it sanely with
scripts/checkincludes.pl, that might be nice.

Now, how does one check all c files for all implicitly included
symbols without writing a complete c parser or generating tons of
false positives? Maybe you can play some trick with "gcc -C -E".

Jörn

-- 
To announce that there must be no criticism of the President, or that we
are to stand by the President, right or wrong, is not only unpatriotic
and servile, but is morally treasonable to the American public.
-- Theodore Roosevelt, Kansas City Star, 1918


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

* Re: missing #includes?
  2003-04-26 20:31 ` Jörn Engel
@ 2003-04-26 20:36   ` Randy.Dunlap
  0 siblings, 0 replies; 5+ messages in thread
From: Randy.Dunlap @ 2003-04-26 20:36 UTC (permalink / raw)
  To: Jörn Engel; +Cc: linux-kernel

On Sat, 26 Apr 2003 22:31:36 +0200 Jörn Engel <joern@wohnheim.fh-wedel.de> wrote:

| On Fri, 25 April 2003 23:51:19 -0700, Randy.Dunlap wrote:
| > 
| > 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.
| 
| As long as it doesn't change the kernel binary, I don't have a strong
| opinion. Explicit #includes are nicer, but is it worth the trouble?
| Do the implicit #includes hurt anywhere? I don't know.

I don't think that it changes the kernel binary (but I haven't tested
that).  Of course the files are being included already, since they
build and since these "missing #include files" are listed in build
files like "kernel/.panic.o.cmd".

Thanks,
--
~Randy

^ 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).