Powered by Linux
Re: about using smatch in all debian C code — Semantic Matching Tool

Re: about using smatch in all debian C code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 09, 2023 at 01:28:35PM +0800, 李书畅 wrote:
> Hello Dan, I am an undergraduate student of Dongliang Mu's team.
> I'm recently working on a project on how to run smatch in all debian
> C code, but I found that there is little documentation on use smatch
> on code other than the linux kernel,so I am having trouble with this
> project.
>
> I'd like to ask you what do I need to do to use smatch (simplifying
> some of the rules is fine) in general C code, and is there
> documentation that can help?

Basically you want to call smatch with all the same arguments that you
pass to GCC plus some specific smatch arguments at the begining.

That's kind of what the cgcc script is supposed to do.  So maybe you
could:
export REAL_CC=$(which gcc)
export CHECK="/path/to/smatch --info"

(The --info argument will generate a ton of output so that's one way to
be sure it's working).

Then if you were just checking one project, I would say to modify the
Makefiles to call cgcc instead of gcc but if you're checking everything
maybe move the real gcc to real_gcc and move cgcc to /usr/bin/gcc

The other issue that you're going to run into is with recursive
Makefiles where it cd's to a different directory before building things.
In that situation the warnings just say "foo.c:123 warning blah blah blah".
So what you want to do is pass --full-path.

export CHECK="/path/to/smatch --info --full-path"

Anyway, I haven't done any of this before so I can't promise it will
work.  Let me know either way.  Let me know any issues you run into and
I'll see what I can do to help.

I'm traveling for a week so I might not very responsive until Nov 20.

regards,
dan carpenter




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux