linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Randy.Dunlap" <randy.dunlap@verizon.net>
To: lkml <linux-kernel@vger.kernel.org>
Subject: missing #includes?
Date: Fri, 25 Apr 2003 23:51:19 -0700	[thread overview]
Message-ID: <20030425235119.6f337e70.randy.dunlap@verizon.net> (raw)

[-- 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

             reply	other threads:[~2003-04-26  6:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-26  6:51 Randy.Dunlap [this message]
2003-04-26 20:17 ` missing #includes? 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030425235119.6f337e70.randy.dunlap@verizon.net \
    --to=randy.dunlap@verizon.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).