Re: thoughts wanted on dead code hunting?

From: Dr. David Alan Gilbert
Date: Thu May 16 2024 - 07:56:23 EST


* Kees Cook (keescook@xxxxxxxxxxxx) wrote:
> On Thu, May 16, 2024 at 12:40:40AM +0000, Dr. David Alan Gilbert wrote:
> > * Kees Cook (keescook@xxxxxxxxxxxx) wrote:
> > > // Options: --recursive-includes
> > > @find@
> > > struct to_be_removed INSTANCE;
> > > struct to_be_removed *POINTER;
>
> Oops, I missed this line:
>
> @@
>
> > >
> > > (
> > > * INSTANCE
> > > |
> > > * POINTER
> > > )
> > >
> > >
> > > (I bet this could be improved, but it should be a usable example.)
> >
> > Hmm, now if I could use coccinelle it would be more tolerant of coding
> > style and slight variations than my script.
> > However, trying that tiny example, I get:
> > File "play.cocci", line 10, column 1, charpos = 141
> > around = '',
> > whole content = )
> >
> > so it seems to be objecting to something at the end of the file?
>
> Sorry, yes, missed the "@@" between the identifiers and the code pattern
> to match.

Ah right, that's done it - I'd noticed there wasn't a @@ but couldn't
figure out where to put them.

After a bit of guessing, I also added a

virtual context

at the top and now:

make coccicheck COCCI=play.cocci M=arch/x86 MODE=context

works - thanks! I'll have a play.

Dave

> --
> Kees Cook
>
--
-----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
\ dave @ treblig.org | | In Hex /
\ _________________________|_____ http://www.treblig.org |_______/