All of lore.kernel.org
 help / color / mirror / Atom feed
* Using Coccinelle to detect bugs
@ 2016-09-17 18:20 Gargi Sharma
  2016-09-17 18:50 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Gargi Sharma @ 2016-09-17 18:20 UTC (permalink / raw)
  To: outreachy-kernel

[-- Attachment #1: Type: text/plain, Size: 954 bytes --]

Hi all!

I have been trying to use Coccinelle scripts but I am getting the error :
Fatal error: exception Failure("False should not be in the final result.
Perhaps your rule doesn't contain any +/-/* code, or you have a failed
dependency.  If the problem is not clear, try the option
--debug-parse-cocci.").

Steps I followed:
1. sudo apt-get install coccinelle
2.  make coccicheck MODE=report
3. run  spatch --sp-file scripts/coccinelle/misc/array_siz.cocci --dir
drivers/staging/*

After which I get the error:
Fatal error: exception Failure("False should not be in the final result.
Perhaps your rule doesn't contain any +/-/* code, or you have a failed
dependency.  If the problem is not clear, try the option
--debug-parse-cocci.").

I would also like to ask that a lot of script mentioned in coccinellery are
not present in scripts/coccinelle. So if I want to run a scipt from
coccinellery, do I clone the coccinellery repo as well?

Thanks!
Gargi

[-- Attachment #2: Type: text/html, Size: 1223 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] Using Coccinelle to detect bugs
  2016-09-17 18:20 Using Coccinelle to detect bugs Gargi Sharma
@ 2016-09-17 18:50 ` Julia Lawall
  2016-09-18 21:57   ` Gargi Sharma
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2016-09-17 18:50 UTC (permalink / raw)
  To: Gargi Sharma; +Cc: outreachy-kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 3383 bytes --]



On Sat, 17 Sep 2016, Gargi Sharma wrote:

> Hi all!
> I have been trying to use Coccinelle scripts but I am getting the error :
> Fatal error: exception Failure("False should not be in the final result. 
> Perhaps your rule doesn't contain any +/-/* code, or you have a failed
> dependency.  If the problem is not clear, try the option
> --debug-parse-cocci.").
>
> Steps I followed:
> 1. sudo apt-get install coccinelle
> 2.  make coccicheck MODE=report
> 3. run  spatch --sp-file scripts/coccinelle/misc/array_siz.cocci --dir
> drivers/staging/*

Either you run make coccicheck or you run spatch with some arguments.
There is no file with the name scripts/coccinelle/misc/array_siz.cocci.
It would be scripts/coccinelle/misc/array_size.cocci.  I don't know if the
typo is in your command line, or if it just came when you sent the email.

The short answer for the error message you got it that you need to run
that semantic patch using make coccicheck.  You can read about how to use
make coccicheck in the Linux kernel documentation, in
dev-tools/coccinelle.rst.

The long answer is that if you look at array_size.cocci, you will see at
the top:

virtual patch
virtual context
virtual org
virtual report

These are virtual rules, that are sort of like #ifdefs.  Basically, they
give you some choices about what kind of behavior you want.  If you want a
patch, ie the issue to be fixed, then when you run spatch, you can give
the command line argument -D patch.  Or if you just want a report, ie some
lines printing the file name and line number where the issue occurs, you
can give the command line -D report.  The various rules in the semantic
patch then depend on these virtual rules.  All of the rules in the
semantic patch that actually do something (make a change or print some
output) depend on these virtual rules in one way or the other.  So if you
don't give one of -D patch, etc, then it will have nothing to do, and you
will get the eror message you saw.

>
> After which I get the error: 
> Fatal error: exception Failure("False should not be in the final result. 
> Perhaps your rule doesn't contain any +/-/* code, or you have a failed
> dependency.  If the problem is not clear, try the option
> --debug-parse-cocci.").
>
> I would also like to ask that a lot of script mentioned in coccinellery are
> not present in scripts/coccinelle. So if I want to run a scipt from
> coccinellery, do I clone the coccinellery repo as well?

Yes.  The scripts in the kernel are things that are considered to be
useful, and to behave well.  The scripts in coccinellery are just random
things that have been collected over time.  You are most welcome to try
them, though.  For those, you run spatch directly, not make coccicheck,
since they don't normally provide any of the virtual rules.

julia

>
> Thanks!
> Gargi
>
> --
> You received this message because you are subscribed to the Google Groups
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/CAOCi2DFRtAPuzNce3oEQGcu
> 6yO388OE%3DfC3SBOS7ywVuebUV5w%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] Using Coccinelle to detect bugs
  2016-09-17 18:50 ` [Outreachy kernel] " Julia Lawall
@ 2016-09-18 21:57   ` Gargi Sharma
  2016-09-19  9:23     ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Gargi Sharma @ 2016-09-18 21:57 UTC (permalink / raw)
  To: Julia Lawall; +Cc: outreachy-kernel

[-- Attachment #1: Type: text/plain, Size: 4112 bytes --]

On Sun, Sep 18, 2016 at 12:20 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
>
> On Sat, 17 Sep 2016, Gargi Sharma wrote:
>
> > Hi all!
> > I have been trying to use Coccinelle scripts but I am getting the error
:
> > Fatal error: exception Failure("False should not be in the final
result.
> > Perhaps your rule doesn't contain any +/-/* code, or you have a failed
> > dependency.  If the problem is not clear, try the option
> > --debug-parse-cocci.").
> >
> > Steps I followed:
> > 1. sudo apt-get install coccinelle
> > 2.  make coccicheck MODE=report
> > 3. run  spatch --sp-file scripts/coccinelle/misc/array_siz.cocci --dir
> > drivers/staging/*
>
> Either you run make coccicheck or you run spatch with some arguments.
> There is no file with the name scripts/coccinelle/misc/array_siz.cocci.
> It would be scripts/coccinelle/misc/array_size.cocci.  I don't know if the
> typo is in your command line, or if it just came when you sent the email.

Yes, that was a typo. I meant to write array_size.cocci.

>
> The short answer for the error message you got it that you need to run
> that semantic patch using make coccicheck.  You can read about how to use
> make coccicheck in the Linux kernel documentation, in
> dev-tools/coccinelle.rst.

make coccicheck MODE=patch returns a coccicheck failed after listing a
few semantic patches. Is something wrong with my kernel build?
Should I purge coccinelle installation and reinstall it?
Also, the documentation folder in my staging-testing tree does not contain
a dev-tools folder. It does have a coccinelle.txt though. Is that the same
as dev-tools/coccinelle.rst?

Thanks for the detailed explanation. It helped clear a lot of things.

gargi

>
> The long answer is that if you look at array_size.cocci, you will see at
> the top:
>
> virtual patch
> virtual context
> virtual org
> virtual report
>
> These are virtual rules, that are sort of like #ifdefs.  Basically, they
> give you some choices about what kind of behavior you want.  If you want a
> patch, ie the issue to be fixed, then when you run spatch, you can give
> the command line argument -D patch.  Or if you just want a report, ie some
> lines printing the file name and line number where the issue occurs, you
> can give the command line -D report.  The various rules in the semantic
> patch then depend on these virtual rules.  All of the rules in the
> semantic patch that actually do something (make a change or print some
> output) depend on these virtual rules in one way or the other.  So if you
> don't give one of -D patch, etc, then it will have nothing to do, and you
> will get the eror message you saw.
>
> >
> > After which I get the error:
> > Fatal error: exception Failure("False should not be in the final
result.
> > Perhaps your rule doesn't contain any +/-/* code, or you have a failed
> > dependency.  If the problem is not clear, try the option
> > --debug-parse-cocci.").
> >
> > I would also like to ask that a lot of script mentioned in coccinellery
are
> > not present in scripts/coccinelle. So if I want to run a scipt from
> > coccinellery, do I clone the coccinellery repo as well?
>
> Yes.  The scripts in the kernel are things that are considered to be
> useful, and to behave well.  The scripts in coccinellery are just random
> things that have been collected over time.  You are most welcome to try
> them, though.  For those, you run spatch directly, not make coccicheck,
> since they don't normally provide any of the virtual rules.
>
> julia
>
> >
> > Thanks!
> > Gargi
> >
> > --
> > You received this message because you are subscribed to the Google
Groups
> > "outreachy-kernel" group.
> > To unsubscribe from this group and stop receiving emails from it, send
an
> > email to outreachy-kernel+unsubscribe@googlegroups.com.
> > To post to this group, send email to outreachy-kernel@googlegroups.com.
> > To view this discussion on the web visithttps://
groups.google.com/d/msgid/outreachy-kernel/CAOCi2DFRtAPuzNce3oEQGcu
> > 6yO388OE%3DfC3SBOS7ywVuebUV5w%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
> >
> >

[-- Attachment #2: Type: text/html, Size: 5323 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] Using Coccinelle to detect bugs
  2016-09-18 21:57   ` Gargi Sharma
@ 2016-09-19  9:23     ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2016-09-19  9:23 UTC (permalink / raw)
  To: Gargi Sharma; +Cc: outreachy-kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 4658 bytes --]



On Mon, 19 Sep 2016, Gargi Sharma wrote:

> On Sun, Sep 18, 2016 at 12:20 AM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >
> >
> >
> > On Sat, 17 Sep 2016, Gargi Sharma wrote:
> >
> > > Hi all!
> > > I have been trying to use Coccinelle scripts but I am getting the error
> :
> > > Fatal error: exception Failure("False should not be in the final result.
> > > Perhaps your rule doesn't contain any +/-/* code, or you have a failed
> > > dependency.  If the problem is not clear, try the option
> > > --debug-parse-cocci.").
> > >
> > > Steps I followed:
> > > 1. sudo apt-get install coccinelle
> > > 2.  make coccicheck MODE=report
> > > 3. run  spatch --sp-file scripts/coccinelle/misc/array_siz.cocci --dir
> > > drivers/staging/*
> >
> > Either you run make coccicheck or you run spatch with some arguments.
> > There is no file with the name scripts/coccinelle/misc/array_siz.cocci.
> > It would be scripts/coccinelle/misc/array_size.cocci.  I don't know if the
> > typo is in your command line, or if it just came when you sent the email.
> Yes, that was a typo. I meant to write array_size.cocci. 
>
> >
> > The short answer for the error message you got it that you need to run
> > that semantic patch using make coccicheck.  You can read about how to use
> > make coccicheck in the Linux kernel documentation, in
> > dev-tools/coccinelle.rst.
>
> make coccicheck MODE=patch returns a coccicheck failed after listing a
> few semantic patches. Is something wrong with my kernel build? 

Failed in what way?

In general, it is not helpful to say that something failed.  You should
for example give some output that shows what went wrong.

It may indeed help to pick up the coccinelle from github.

> Should I purge coccinelle installation and reinstall it?
> Also, the documentation folder in my staging-testing tree does not contain
> a dev-tools folder. It does have a coccinelle.txt though. Is that the same
> as dev-tools/coccinelle.rst?

Yes, that would be fine.  I was probably looking in linux-next.

julia

> Thanks for the detailed explanation. It helped clear a lot of things.
>
> gargi
>
> >
> > The long answer is that if you look at array_size.cocci, you will see at
> > the top:
> >
> > virtual patch
> > virtual context
> > virtual org
> > virtual report
> >
> > These are virtual rules, that are sort of like #ifdefs.  Basically, they
> > give you some choices about what kind of behavior you want.  If you want a
> > patch, ie the issue to be fixed, then when you run spatch, you can give
> > the command line argument -D patch.  Or if you just want a report, ie some
> > lines printing the file name and line number where the issue occurs, you
> > can give the command line -D report.  The various rules in the semantic
> > patch then depend on these virtual rules.  All of the rules in the
> > semantic patch that actually do something (make a change or print some
> > output) depend on these virtual rules in one way or the other.  So if you
> > don't give one of -D patch, etc, then it will have nothing to do, and you
> > will get the eror message you saw.
> >
> > >
> > > After which I get the error:
> > > Fatal error: exception Failure("False should not be in the final result.
> > > Perhaps your rule doesn't contain any +/-/* code, or you have a failed
> > > dependency.  If the problem is not clear, try the option
> > > --debug-parse-cocci.").
> > >
> > > I would also like to ask that a lot of script mentioned in coccinellery
> are
> > > not present in scripts/coccinelle. So if I want to run a scipt from
> > > coccinellery, do I clone the coccinellery repo as well?
> >
> > Yes.  The scripts in the kernel are things that are considered to be
> > useful, and to behave well.  The scripts in coccinellery are just random
> > things that have been collected over time.  You are most welcome to try
> > them, though.  For those, you run spatch directly, not make coccicheck,
> > since they don't normally provide any of the virtual rules.
> >
> > julia
> >
> > >
> > > Thanks!
> > > Gargi
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "outreachy-kernel" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> an
> > > email to outreachy-kernel+unsubscribe@googlegroups.com.
> > > To post to this group, send email to outreachy-kernel@googlegroups.com.
> > > To view this discussion on the webvisithttps://groups.google.com/d/msgid/outreachy-kernel/CAOCi2DFRtAPuzNce3o
> EQGcu
> > > 6yO388OE%3DfC3SBOS7ywVuebUV5w%40mail.gmail.com.
> > > For more options, visit https://groups.google.com/d/optout.
> > >
> > >
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-19  9:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-17 18:20 Using Coccinelle to detect bugs Gargi Sharma
2016-09-17 18:50 ` [Outreachy kernel] " Julia Lawall
2016-09-18 21:57   ` Gargi Sharma
2016-09-19  9:23     ` Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.