Coccinelle archive on lore.kernel.org
 help / Atom feed
* [Cocci] Fatal exception in spatch when #include file does not exist
@ 2019-01-22 19:31 Timur Tabi
  2019-01-22 19:44 ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Timur Tabi @ 2019-01-22 19:31 UTC (permalink / raw)
  To: cocci

Let's say I have these files:

dir1/dir2/dir3/file1.h
dir1/dir2/dir4/dir5/file2.c

In file2.c, I have this include statement:

#include "../../dir3/file1.h"

This works if I compile the file when I'm in the dir5 directory.

However, if I am in the dir4 directory and do this:

spatch ... ./dir5/file2.c

I will get this error:

Fatal error: exception Sys_error("../../dir3/file1.h": No such file or
directory")

which is technically true, but so what?  Does spatch actually try to
read the contents of file1.h?  If not, why does it care whether the
file exists?  And why doesn't it just ignore the #include line?
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Fatal exception in spatch when #include file does not exist
  2019-01-22 19:31 [Cocci] Fatal exception in spatch when #include file does not exist Timur Tabi
@ 2019-01-22 19:44 ` Julia Lawall
  2019-01-22 20:39   ` Timur Tabi
  0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2019-01-22 19:44 UTC (permalink / raw)
  To: Timur Tabi; +Cc: cocci



On Tue, 22 Jan 2019, Timur Tabi wrote:

> Let's say I have these files:
>
> dir1/dir2/dir3/file1.h
> dir1/dir2/dir4/dir5/file2.c
>
> In file2.c, I have this include statement:
>
> #include "../../dir3/file1.h"
>
> This works if I compile the file when I'm in the dir5 directory.
>
> However, if I am in the dir4 directory and do this:
>
> spatch ... ./dir5/file2.c
>
> I will get this error:
>
> Fatal error: exception Sys_error("../../dir3/file1.h": No such file or
> directory")
>
> which is technically true, but so what?  Does spatch actually try to
> read the contents of file1.h?  If not, why does it care whether the
> file exists?  And why doesn't it just ignore the #include line?

If you get such a message, it means that the options were such that it
wants to read the header file.  By default, the option is --local-includes
which includes things mentioned with " " and headers with the same name as
the .c file.

I guess that it is not interpreting the ../ properly, at least when you
specify a path to a specific file.

If you want all the header files to be ignored, just give the argument
--no-includes.  If you give the argument --include-headers and give spatch
the name of a directory or of a .h file, it will process individually the
.h files as well as the .c files

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Fatal exception in spatch when #include file does not exist
  2019-01-22 19:44 ` Julia Lawall
@ 2019-01-22 20:39   ` Timur Tabi
  2019-01-22 20:48     ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Timur Tabi @ 2019-01-22 20:39 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci, Timur Tabi

On Tue, Jan 22, 2019 at 1:53 PM Julia Lawall <julia.lawall@lip6.fr> wrote:

> If you want all the header files to be ignored, just give the argument
> --no-includes.

What does spatch actually do with the header files that it reads?
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Fatal exception in spatch when #include file does not exist
  2019-01-22 20:39   ` Timur Tabi
@ 2019-01-22 20:48     ` Julia Lawall
  2019-01-22 22:06       ` Timur Tabi
  0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2019-01-22 20:48 UTC (permalink / raw)
  To: Timur Tabi; +Cc: cocci



On Tue, 22 Jan 2019, Timur Tabi wrote:

> On Tue, Jan 22, 2019 at 1:53 PM Julia Lawall <julia.lawall@lip6.fr> wrote:
>
> > If you want all the header files to be ignored, just give the argument
> > --no-includes.
>
> What does spatch actually do with the header files that it reads?

It finds type information.  It also matches your rules against the
definitions found in the header files, just like it matches the rules
against the definitions found in the .c files.

julia
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Fatal exception in spatch when #include file does not exist
  2019-01-22 20:48     ` Julia Lawall
@ 2019-01-22 22:06       ` Timur Tabi
       [not found]         ` <b73ba628-ee07-5962-0f17-72cebfa14954@users.sourceforge.net>
  0 siblings, 1 reply; 6+ messages in thread
From: Timur Tabi @ 2019-01-22 22:06 UTC (permalink / raw)
  To: Julia Lawall; +Cc: cocci, Timur Tabi

On Tue, Jan 22, 2019 at 2:48 PM Julia Lawall <julia.lawall@lip6.fr> wrote:
> It finds type information.  It also matches your rules against the
> definitions found in the header files, just like it matches the rules
> against the definitions found in the .c files.

What happens when it matches a rule in a header file?  Does that mean
that it will try to edit the header file as well?

It seems to me for my DBG_PRINTF changes, I definitely want --no-includes.
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

* Re: [Cocci] Source code adjustments in header files?
       [not found]         ` <b73ba628-ee07-5962-0f17-72cebfa14954@users.sourceforge.net>
@ 2019-01-23 16:14           ` Timur Tabi
  0 siblings, 0 replies; 6+ messages in thread
From: Timur Tabi @ 2019-01-23 16:14 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: cocci

On 1/23/19 7:28 AM, SF Markus Elfring wrote:
>> It seems to me for my DBG_PRINTF changes, I definitely want --no-includes.

> How do you think about to adjust any macro calls also in header files?

When I specify a file name on the spatch command line, I don't want any 
other file modified.  If I wanted to modify a header file, I'd tell 
spatch to modify that header file.
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-22 19:31 [Cocci] Fatal exception in spatch when #include file does not exist Timur Tabi
2019-01-22 19:44 ` Julia Lawall
2019-01-22 20:39   ` Timur Tabi
2019-01-22 20:48     ` Julia Lawall
2019-01-22 22:06       ` Timur Tabi
     [not found]         ` <b73ba628-ee07-5962-0f17-72cebfa14954@users.sourceforge.net>
2019-01-23 16:14           ` [Cocci] Source code adjustments in header files? Timur Tabi

Coccinelle archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/cocci/0 cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ https://lore.kernel.org/cocci \
		cocci@systeme.lip6.fr cocci@archiver.kernel.org
	public-inbox-index cocci


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/fr.lip6.systeme.cocci


AGPL code for this site: git clone https://public-inbox.org/ public-inbox