2007-11-04 17:33:12

by Robert P. J. Day

[permalink] [raw]
Subject: duplicated include files


given the recent patches to remove duplicated #include preprocessor
directives in source files, let it be known that there are a number of
them:

http://www.crashcourse.ca/wiki/index.php/Duplicate_include_files

help yourself.

rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================


2007-11-04 18:09:49

by Randy Dunlap

[permalink] [raw]
Subject: Re: duplicated include files

On Sun, 4 Nov 2007 12:31:38 -0500 (EST) Robert P. J. Day wrote:

>
> given the recent patches to remove duplicated #include preprocessor
> directives in source files, let it be known that there are a number of
> them:
>
> http://www.crashcourse.ca/wiki/index.php/Duplicate_include_files
>
> help yourself.

Could you make the tool (script?) available also, please?

---
~Randy

2007-11-04 18:39:09

by Robert P. J. Day

[permalink] [raw]
Subject: Re: duplicated include files

On Sun, 4 Nov 2007, Randy Dunlap wrote:

> On Sun, 4 Nov 2007 12:31:38 -0500 (EST) Robert P. J. Day wrote:
>
> >
> > given the recent patches to remove duplicated #include preprocessor
> > directives in source files, let it be known that there are a number of
> > them:
> >
> > http://www.crashcourse.ca/wiki/index.php/Duplicate_include_files
> >
> > help yourself.
>
> Could you make the tool (script?) available also, please?

trust me, it's not a script i'm particularly proud of:

===========================
#!/bin/sh

DIR=${1-*} # by default, all directories

for cf in $(find ${DIR} -name *.c) ; do
echo ${cf}
grep "#include" $cf | sort | uniq -c | grep -v 1
done | grep -B1 "#include" | grep -v -- "--"
===========================

on the bright side, it took about 90 seconds to write, but i won't
be winning any awards for style.

i'll add it to the web page.

rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================

2007-11-04 18:47:19

by Randy Dunlap

[permalink] [raw]
Subject: Re: duplicated include files

On Sun, 4 Nov 2007 13:37:31 -0500 (EST) Robert P. J. Day wrote:

> On Sun, 4 Nov 2007, Randy Dunlap wrote:
>
> > On Sun, 4 Nov 2007 12:31:38 -0500 (EST) Robert P. J. Day wrote:
> >
> > >
> > > given the recent patches to remove duplicated #include preprocessor
> > > directives in source files, let it be known that there are a number of
> > > them:
> > >
> > > http://www.crashcourse.ca/wiki/index.php/Duplicate_include_files
> > >
> > > help yourself.
> >
> > Could you make the tool (script?) available also, please?
>
> trust me, it's not a script i'm particularly proud of:
>
> ===========================
> #!/bin/sh
>
> DIR=${1-*} # by default, all directories
>
> for cf in $(find ${DIR} -name *.c) ; do
> echo ${cf}
> grep "#include" $cf | sort | uniq -c | grep -v 1
> done | grep -B1 "#include" | grep -v -- "--"
> ===========================
>
> on the bright side, it took about 90 seconds to write, but i won't
> be winning any awards for style.
>
> i'll add it to the web page.

Thanks!

---
~Randy

2007-11-04 19:04:21

by Adrian Bunk

[permalink] [raw]
Subject: Re: duplicated include files

On Sun, Nov 04, 2007 at 01:37:31PM -0500, Robert P. J. Day wrote:
> On Sun, 4 Nov 2007, Randy Dunlap wrote:
>
> > On Sun, 4 Nov 2007 12:31:38 -0500 (EST) Robert P. J. Day wrote:
> >
> > >
> > > given the recent patches to remove duplicated #include preprocessor
> > > directives in source files, let it be known that there are a number of
> > > them:
> > >
> > > http://www.crashcourse.ca/wiki/index.php/Duplicate_include_files
> > >
> > > help yourself.
> >
> > Could you make the tool (script?) available also, please?
>
> trust me, it's not a script i'm particularly proud of:
>
> ===========================
> #!/bin/sh
>
> DIR=${1-*} # by default, all directories
>
> for cf in $(find ${DIR} -name *.c) ; do
> echo ${cf}
> grep "#include" $cf | sort | uniq -c | grep -v 1
> done | grep -B1 "#include" | grep -v -- "--"
> ===========================
>
> on the bright side, it took about 90 seconds to write, but i won't
> be winning any awards for style.
>
> i'll add it to the web page.


BTW: "make includecheck" already does the same...


> rday


cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2007-11-04 19:12:15

by Robert P. J. Day

[permalink] [raw]
Subject: Re: duplicated include files

On Sun, 4 Nov 2007, Adrian Bunk wrote:

> BTW: "make includecheck" already does the same...

oh ... well, then, let's just ignore the last few postings, shall we?
:-P

rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================

2007-11-04 19:42:15

by Marco Costalba

[permalink] [raw]
Subject: Re: duplicated include files

make includecheck does not work for me. Linux tree is from latest git.

bash-3.2$ pwd
/git/linux-2.6

bash-3.2$ make includecheck
find * \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o
-name .pc -o -name .hg -o -name .git \) -prune -o \
-name '*.[hcS]' -type f -print | sort \
| xargs perl -w scripts/checkincludes.pl
Can't open perl script "scripts/checkincludes.pl": No such file or directory
make[1]: *** [includecheck] Error 123
make: *** [sub-make] Error 2

bash-3.2$ ls scripts/checkincludes.pl
scripts/checkincludes.pl

2007-11-04 19:43:18

by Marco Costalba

[permalink] [raw]
Subject: Re: duplicated include files

On 11/4/07, Marco Costalba <[email protected]> wrote:
> make includecheck does not work for me. Linux tree is from latest git.
>
> bash-3.2$ pwd
> /git/linux-2.6
>
> bash-3.2$ make includecheck
> find * \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o

BTW what's that 'BitKeeper' fossil here?

2007-11-04 19:50:36

by Robert P. J. Day

[permalink] [raw]
Subject: Re: duplicated include files

On Sun, 4 Nov 2007, Marco Costalba wrote:

> On 11/4/07, Marco Costalba <[email protected]> wrote:
> > make includecheck does not work for me. Linux tree is from latest git.
> >
> > bash-3.2$ pwd
> > /git/linux-2.6
> >
> > bash-3.2$ make includecheck
> > find * \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o
>
> BTW what's that 'BitKeeper' fossil here?

actually, one wonders if there's any value in keeping any references
to other version control systems such as subversion, SCCS, CVS,
mercurial, etc.

rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================

2007-11-04 19:52:11

by Randy Dunlap

[permalink] [raw]
Subject: Re: duplicated include files

On Sun, 4 Nov 2007 20:43:01 +0100 Marco Costalba wrote:

> On 11/4/07, Marco Costalba <[email protected]> wrote:
> > make includecheck does not work for me. Linux tree is from latest git.
> >
> > bash-3.2$ pwd
> > /git/linux-2.6
> >
> > bash-3.2$ make includecheck
> > find * \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o
>
> BTW what's that 'BitKeeper' fossil here?

It allows people to continue using any of {CVS, SVN, BitKeeper}
for their kernel tree. The BK kernel tree is still being updated
AFAIK. (It was last time I looked, about 3 weeks ago.)

---
~Randy

2007-11-04 23:21:25

by Jeremy Fitzhardinge

[permalink] [raw]
Subject: Re: duplicated include files

Robert P. J. Day wrote:
> actually, one wonders if there's any value in keeping any references
> to other version control systems such as subversion, SCCS, CVS,
> mercurial, etc.
>

What do you mean by "other"? git doesn't have a monopoly, and the
kernel should support people using a reasonable set of version control
systems. Supporting VSS would be strange, but nothing wrong with the
set you listed, if people find those systems useful. It's not like it
amounts to a huge amount of effort to do so.

J

2007-11-04 23:44:11

by Bernd Petrovitsch

[permalink] [raw]
Subject: Re: duplicated include files

On Sun, 2007-11-04 at 14:49 -0500, Robert P. J. Day wrote:
[...]
> actually, one wonders if there's any value in keeping any references
> to other version control systems such as subversion, SCCS, CVS,
> mercurial, etc.

Lots of people have their working trees in CVS, Subversion, ....
So it probably annoys them and doesn't really buy anything IMHO.

Bernd
--
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services

2007-11-05 03:03:06

by Paul Mundt

[permalink] [raw]
Subject: Re: duplicated include files

On Sun, Nov 04, 2007 at 08:03:48PM +0100, Adrian Bunk wrote:
> BTW: "make includecheck" already does the same...
>
When was that added? It's not listed in the 'make help', and I see
there's a versioncheck too that's not reported. Some of these are
actually useful, I wonder what else is lurking in the depths of
undocumented Makefile target land ;-)

docs: Add includecheck/versioncheck to 'make help'

Signed-off-by: Paul Mundt <[email protected]>

---

diff --git a/Makefile b/Makefile
index 188c3b6..1ab40ac 100644
--- a/Makefile
+++ b/Makefile
@@ -1168,6 +1168,8 @@ help:
@echo ''
@echo 'Static analysers'
@echo ' checkstack - Generate a list of stack hogs'
+ @echo ' versioncheck - Sanity check on version.h usage'
+ @echo ' includecheck - Sanity check on duplicate includes'
@echo ' namespacecheck - Name space analysis on compiled kernel'
@echo ' export_report - List the usages of all exported symbols'
@if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \

2007-11-05 03:50:46

by Robert P. J. Day

[permalink] [raw]
Subject: Re: duplicated include files

On Sun, 4 Nov 2007, Jeremy Fitzhardinge wrote:

> Robert P. J. Day wrote:
> > actually, one wonders if there's any value in keeping any references
> > to other version control systems such as subversion, SCCS, CVS,
> > mercurial, etc.
>
> What do you mean by "other"? git doesn't have a monopoly, and the
> kernel should support people using a reasonable set of version
> control systems. Supporting VSS would be strange, but nothing wrong
> with the set you listed, if people find those systems useful. It's
> not like it amounts to a huge amount of effort to do so.

you're right, my mistake, i was just caught up in a git-centered
perspective.

rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================

2007-11-05 08:27:30

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: duplicated include files

On Sun, 4 Nov 2007, Robert P. J. Day wrote:
> given the recent patches to remove duplicated #include preprocessor
> directives in source files, let it be known that there are a number of
> them:
>
> http://www.crashcourse.ca/wiki/index.php/Duplicate_include_files
>
> help yourself.

Thanks!

drivers/scsi/gvp11.c is a false positive, as it includes "gvp11.h" once
without HOSTS_C defined and once with.

drivers/scsi/mvme147.c looks similar, but "mvme147.h" does not check for
HOSTS_C (anymore?).

But both need a cleanup anyway...

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2007-11-05 10:51:55

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: duplicated include files

On Sun, 4 Nov 2007, Marco Costalba wrote:
> make includecheck does not work for me. Linux tree is from latest git.
>
> bash-3.2$ pwd
> /git/linux-2.6
>
> bash-3.2$ make includecheck
> find * \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o
> -name .pc -o -name .hg -o -name .git \) -prune -o \
> -name '*.[hcS]' -type f -print | sort \
> | xargs perl -w scripts/checkincludes.pl
> Can't open perl script "scripts/checkincludes.pl": No such file or directory
> make[1]: *** [includecheck] Error 123
> make: *** [sub-make] Error 2
>
> bash-3.2$ ls scripts/checkincludes.pl
> scripts/checkincludes.pl

Are you building in a different tree than the source tree? The patch below
fixed it for me.

Question: Why don't GENKSYMS and KALLSYMS need the $(srctree) prefix?
---
Subject: kbuild: Add missing srctree prefix for includecheck and versioncheck

Add missing $(srctree)/ prefix for scripts used by the includecheck and
versioncheck make targets

Signed-off-by: Geert Uytterhoeven <[email protected]>
---
Makefile | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -1414,12 +1414,12 @@ tags: FORCE
includecheck:
find * $(RCS_FIND_IGNORE) \
-name '*.[hcS]' -type f -print | sort \
- | xargs $(PERL) -w scripts/checkincludes.pl
+ | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl

versioncheck:
find * $(RCS_FIND_IGNORE) \
-name '*.[hcS]' -type f -print | sort \
- | xargs $(PERL) -w scripts/checkversion.pl
+ | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl

namespacecheck:
$(PERL) $(srctree)/scripts/namespace.pl

With kind regards,

Geert Uytterhoeven
Software Architect

Sony Network and Software Technology Center Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone: +32 (0)2 700 8453
Fax: +32 (0)2 700 8622
E-mail: [email protected]
Internet: http://www.sony-europe.com/

Sony Network and Software Technology Center Europe
A division of Sony Service Centre (Europe) N.V.
Registered office: Technologielaan 7 · B-1840 Londerzeel · Belgium
VAT BE 0413.825.160 · RPR Brussels
Fortis Bank Zaventem · Swift GEBABEBB08A · IBAN BE39001382358619

2007-11-05 11:38:57

by Marco Costalba

[permalink] [raw]
Subject: Re: duplicated include files

On 11/5/07, Geert Uytterhoeven <[email protected]> wrote:
>
> Are you building in a different tree than the source tree? The patch below
> fixed it for me.
>

Yes, I am. Thanks for the patch.

Marco

2007-11-14 20:38:57

by Sam Ravnborg

[permalink] [raw]
Subject: Re: duplicated include files

>
> Are you building in a different tree than the source tree? The patch below
> fixed it for me.
>
> Question: Why don't GENKSYMS and KALLSYMS need the $(srctree) prefix?

They are generated binaries that live in the output directory structure.

> ---
> Subject: kbuild: Add missing srctree prefix for includecheck and versioncheck
>
> Add missing $(srctree)/ prefix for scripts used by the includecheck and
> versioncheck make targets
>
> Signed-off-by: Geert Uytterhoeven <[email protected]>

Thanks - applied.

Sam