Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1638278 > unrolled thread
| Started by | Randy Dunlap <rdunlap@infradead.org> |
|---|---|
| First post | 2017-05-09 18:50 +0200 |
| Last post | 2017-05-10 23:00 +0200 |
| Articles | 7 — 3 participants |
Back to article view | Back to linux.kernel
sparse on scripts/kconfig/*.c Randy Dunlap <rdunlap@infradead.org> - 2017-05-09 18:50 +0200
Re: sparse on scripts/kconfig/*.c Christoph Hellwig <hch@infradead.org> - 2017-05-09 22:20 +0200
Re: sparse on scripts/kconfig/*.c Randy Dunlap <rdunlap@infradead.org> - 2017-05-10 02:30 +0200
Re: sparse on scripts/kconfig/*.c Christoph Hellwig <hch@infradead.org> - 2017-05-10 09:30 +0200
Re: sparse on scripts/kconfig/*.c Randy Dunlap <rdunlap@infradead.org> - 2017-05-10 18:50 +0200
Re: sparse on scripts/kconfig/*.c Dan Carpenter <dan.carpenter@oracle.com> - 2017-05-10 12:20 +0200
Re: sparse on scripts/kconfig/*.c Dan Carpenter <dan.carpenter@oracle.com> - 2017-05-10 23:00 +0200
| From | Randy Dunlap <rdunlap@infradead.org> |
|---|---|
| Date | 2017-05-09 18:50 +0200 |
| Subject | sparse on scripts/kconfig/*.c |
| Message-ID | <tFguJ-4li-3@gated-at.bofh.it> |
Hi, I've been attempting to run sparse on the kconfig/ C files -- without success. The kbuild files don't try to support CHECK in scripts/kconfig/ AFAICT, and just running sparse on the C files has issues with not being able to find header files. Has anyone done this? Any clues about how to do it? thanks, -- ~Randy
[toc] | [next] | [standalone]
| From | Christoph Hellwig <hch@infradead.org> |
|---|---|
| Date | 2017-05-09 22:20 +0200 |
| Message-ID | <tFjLX-6Gn-5@gated-at.bofh.it> |
| In reply to | #1638278 |
On Tue, May 09, 2017 at 09:47:41AM -0700, Randy Dunlap wrote: > Hi, > > I've been attempting to run sparse on the kconfig/ C files -- without success. > > The kbuild files don't try to support CHECK in scripts/kconfig/ AFAICT, > and just running sparse on the C files has issues with not being able to > find header files. > > Has anyone done this? Any clues about how to do it? As a wild guess from using sparse on various userspace projects: have you tried simply setting HOSTCC to cgcc?
[toc] | [prev] | [next] | [standalone]
| From | Randy Dunlap <rdunlap@infradead.org> |
|---|---|
| Date | 2017-05-10 02:30 +0200 |
| Message-ID | <tFnFU-MR-5@gated-at.bofh.it> |
| In reply to | #1638390 |
On 05/09/17 13:17, Christoph Hellwig wrote: > On Tue, May 09, 2017 at 09:47:41AM -0700, Randy Dunlap wrote: >> Hi, >> >> I've been attempting to run sparse on the kconfig/ C files -- without success. >> >> The kbuild files don't try to support CHECK in scripts/kconfig/ AFAICT, >> and just running sparse on the C files has issues with not being able to >> find header files. >> >> Has anyone done this? Any clues about how to do it? > > As a wild guess from using sparse on various userspace projects: > > have you tried simply setting HOSTCC to cgcc? I don't quite see what that has to do with running sparse ($CHECK, not $HOSTCC). Anyway, I tried it and got the same message: nconf.h:19:11: error: unable to open 'menu.h' thanks. -- ~Randy
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@infradead.org> |
|---|---|
| Date | 2017-05-10 09:30 +0200 |
| Message-ID | <tFuel-6dd-1@gated-at.bofh.it> |
| In reply to | #1638465 |
On Tue, May 09, 2017 at 05:27:01PM -0700, Randy Dunlap wrote: > On 05/09/17 13:17, Christoph Hellwig wrote: > > On Tue, May 09, 2017 at 09:47:41AM -0700, Randy Dunlap wrote: > >> Hi, > >> > >> I've been attempting to run sparse on the kconfig/ C files -- without success. > >> > >> The kbuild files don't try to support CHECK in scripts/kconfig/ AFAICT, > >> and just running sparse on the C files has issues with not being able to > >> find header files. > >> > >> Has anyone done this? Any clues about how to do it? > > > > As a wild guess from using sparse on various userspace projects: > > > > have you tried simply setting HOSTCC to cgcc? > > I don't quite see what that has to do with running sparse ($CHECK, not $HOSTCC). cgcc is a gcc wrappr that calls sparse. I just trie quickly to patch Makefile to run cgcc instead of gcc as HOSTCC an it seems to work: HOSTCC scripts/basic/fixdep scripts/basic/fixdep.c:117:5: warning: symbol 'insert_extra_deps' was not declared. Should it be static? scripts/basic/fixdep.c:118:6: warning: symbol 'target' was not declared. Should it be static? scripts/basic/fixdep.c:119:6: warning: symbol 'depfile' was not declared. Should it be static? scripts/basic/fixdep.c:120:6: warning: symbol 'cmdline' was not declared. Should it be static? But then I run into the known cgcc bug that it also calls sparse when called for linking. Which reminds me that I need to go back and fix that.
[toc] | [prev] | [next] | [standalone]
| From | Randy Dunlap <rdunlap@infradead.org> |
|---|---|
| Date | 2017-05-10 18:50 +0200 |
| Message-ID | <tFCYh-34M-9@gated-at.bofh.it> |
| In reply to | #1638604 |
On 05/10/17 00:28, Christoph Hellwig wrote: > On Tue, May 09, 2017 at 05:27:01PM -0700, Randy Dunlap wrote: >> On 05/09/17 13:17, Christoph Hellwig wrote: >>> On Tue, May 09, 2017 at 09:47:41AM -0700, Randy Dunlap wrote: >>>> Hi, >>>> >>>> I've been attempting to run sparse on the kconfig/ C files -- without success. >>>> >>>> The kbuild files don't try to support CHECK in scripts/kconfig/ AFAICT, >>>> and just running sparse on the C files has issues with not being able to >>>> find header files. >>>> >>>> Has anyone done this? Any clues about how to do it? >>> >>> As a wild guess from using sparse on various userspace projects: >>> >>> have you tried simply setting HOSTCC to cgcc? >> >> I don't quite see what that has to do with running sparse ($CHECK, not $HOSTCC). > > cgcc is a gcc wrappr that calls sparse. I just trie quickly to patch > Makefile to run cgcc instead of gcc as HOSTCC an it seems to work: > > HOSTCC scripts/basic/fixdep Agreed, that does it. > scripts/basic/fixdep.c:117:5: warning: symbol 'insert_extra_deps' was not declared. Should it be static? > scripts/basic/fixdep.c:118:6: warning: symbol 'target' was not declared. Should it be static? > scripts/basic/fixdep.c:119:6: warning: symbol 'depfile' was not declared. Should it be static? > scripts/basic/fixdep.c:120:6: warning: symbol 'cmdline' was not declared. Should it be static? > > But then I run into the known cgcc bug that it also calls sparse when > called for linking. Which reminds me that I need to go back and fix > that. > Thanks to both you and Dan for your help. -- ~Randy
[toc] | [prev] | [next] | [standalone]
| From | Dan Carpenter <dan.carpenter@oracle.com> |
|---|---|
| Date | 2017-05-10 12:20 +0200 |
| Message-ID | <tFwSS-7SQ-9@gated-at.bofh.it> |
| In reply to | #1638278 |
On Tue, May 09, 2017 at 09:47:41AM -0700, Randy Dunlap wrote:
> Hi,
>
> I've been attempting to run sparse on the kconfig/ C files -- without success.
>
> The kbuild files don't try to support CHECK in scripts/kconfig/ AFAICT,
> and just running sparse on the C files has issues with not being able to
> find header files.
>
> Has anyone done this? Any clues about how to do it?
>
Smatch has pretty much only been used on kernel code, and it really
shows. For userspace code, you'd want to make a list of the no return
functions and some other customizations. Also the kernel uses a quite
limitted sample of C.
Anyway, what Christophe said is right. Change the Makefile:
-HOSTCC = gcc
+HOSTCC = ~/progs/smatch/devel/cgcc
make CHECK="~/progs/smatch/devel/smatch --file-output" scripts/kconfig/
find -name \*.c.smatch -exec cat \{\} \; > smatch_warns.txt
I just did that now, and there is nothing interesting there. If there
were something there, then there is a good chance I would have seen it
already because I've been running smatch_scripts/kchecker on every .c
file. Say you don't have your .config set up for sparc then it doesn't
really work great, but what it does it uses the x86 headers but if there
are any header files missing it just includes a promising header with
the same name or it continues without the .h file. The output is mostly
garbage but I had five sparc patches merged in 2016 so I'm a top ten
sparc dev for the year. :P
regards,
dan carpenter
[toc] | [prev] | [next] | [standalone]
| From | Dan Carpenter <dan.carpenter@oracle.com> |
|---|---|
| Date | 2017-05-10 23:00 +0200 |
| Message-ID | <tFGSe-5qI-7@gated-at.bofh.it> |
| In reply to | #1638730 |
I have created some new tools to make this process easier. 1) First you still have to edit the Makefile: -HOSTCC = gcc +HOSTCC = ~/progs/smatch/devel/cgcc 2) Build the data with this command: ~/progs/smatch/devel/smatch_scripts/build_generic_data.sh --target scripts/ The --target scripts/ is because we want to run smatch on the scripts/ directory. 3) Run smatch: ~/progs/smatch/devel/smatch_scripts/test_generic.sh --target scripts/ I just wrote this code today so it might be a bit rough perhaps. Let me know if you have any issues. It doesn't find anything like I said before, but hopefully this can help other people who want to run Smatch on user space code. regards, dan carpenter
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web