Re: Coccinelle: semantic patch for missing of_node_put

2019-06-04 Thread Markus Elfring
> let add_function f c = > if not (List.mem f !relevant_functions) > then > begin > let s = String.concat " " > ( > (List.map String.lowercase_ascii >(List.filter > (function x -> >Str.string_match >

Re: Coccinelle: semantic patch for missing of_node_put

2019-06-04 Thread Markus Elfring
>> Thus I imagine that an other documentation format would be safer >> and more helpful for the determination of a corresponding API >> system property. > > Our script will remove '* ','\ n','\t' and so on from the comments in the > function header > and then merge them into one line, * Would

Re: [Cocci] Coccinelle: semantic patch for missing of_node_put

2019-06-04 Thread wen.yang99
> > We currently use the following Ocaml script to automatically > > collect functions that need to be considered. > > > > @initialize:ocaml@ > > @@ > > > > let relevant_str = "use of_node_put() on it when done" > > I suggest to reconsider this search pattern. > > The mentioned words are

Re: Coccinelle: semantic patch for missing of_node_put

2019-06-04 Thread Markus Elfring
> We currently use the following Ocaml script to automatically > collect functions that need to be considered. > > @initialize:ocaml@ > @@ > > let relevant_str = "use of_node_put() on it when done" I suggest to reconsider this search pattern. The mentioned words are distributed over text lines

Re: [Cocci] Coccinelle: semantic patch for missing of_node_put

2019-06-03 Thread wen.yang99
> > 2, A general method. > > We also try to get the list of functions to consider by writing a SmPL, > > but this method is not feasible at present, because it is not easy to parse > > the comment > > header information of these functions. > > The situation was improved once more also for the

Re: Coccinelle: semantic patch for missing of_node_put

2019-06-03 Thread Markus Elfring
> 2, A general method. > We also try to get the list of functions to consider by writing a SmPL, > but this method is not feasible at present, because it is not easy to parse > the comment > header information of these functions. The situation was improved once more also for the Coccinelle

Re: Coccinelle: semantic patch for missing of_node_put

2019-05-20 Thread Markus Elfring
> On the other hand, I don't know if the one that seemed to cause a crash > really caused a crash. It was detected by syzkaller, and it is also > possible that git bisect ended up at the wrong place. Do you refer to any known bug report here? > In any case, forgetting an of_node_put will

Re: [Cocci] Coccinelle: semantic patch for missing of_node_put

2019-05-20 Thread Julia Lawall
On Mon, 20 May 2019, Sasha Levin wrote: > On Mon, May 20, 2019 at 11:52:37AM +0200, Julia Lawall wrote: > > > > > > On Mon, 20 May 2019, Pavel Machek wrote: > > > > > Hi! > > > > > > > A semantic patch has no access to comments. The only thing I can see to > > > > do is to use python to

Re: Coccinelle: semantic patch for missing of_node_put

2019-05-20 Thread Sasha Levin
On Mon, May 20, 2019 at 11:52:37AM +0200, Julia Lawall wrote: On Mon, 20 May 2019, Pavel Machek wrote: Hi! > A semantic patch has no access to comments. The only thing I can see to > do is to use python to interact with some external tools. For example, > you could write some code to

Re: [Cocci] Coccinelle: semantic patch for missing of_node_put

2019-05-20 Thread Julia Lawall
On Mon, 20 May 2019, Pavel Machek wrote: > Hi! > > > A semantic patch has no access to comments. The only thing I can see to > > do is to use python to interact with some external tools. For example, > > you could write some code to collect the comments in a file and the lines > > on which

Re: [Cocci] Coccinelle: semantic patch for missing of_node_put

2019-05-20 Thread Markus Elfring
> $ spatch --tokens-c drivers/of/base.c 2>&1 | grep "Tag3 " | grep > "of_node_put() on it when done." | awk -F " - " '{print $1}' | grep -o > "of_[[:print:]]*" This command example points some details out for further software development considerations. 1. I find it questionable that

Re: Coccinelle: semantic patch for missing of_node_put

2019-05-20 Thread Julia Lawall
On Mon, 20 May 2019, Pavel Machek wrote: > Hi! > > > A semantic patch has no access to comments. The only thing I can see to > > do is to use python to interact with some external tools. For example, > > you could write some code to collect the comments in a file and the lines > > on which

Re: Coccinelle: semantic patch for missing of_node_put

2019-05-20 Thread Pavel Machek
Hi! > A semantic patch has no access to comments. The only thing I can see to > do is to use python to interact with some external tools. For example, > you could write some code to collect the comments in a file and the lines > on which they occur, and then get the comment that most closely

Re: Coccinelle: semantic patch for missing of_node_put

2019-05-17 Thread Markus Elfring
> A semantic patch has no access to comments. Thanks for your acknowledgement of the current situation. > The only thing I can see to do is to use python to interact with some > external tools. I see more software development possibilities. * Advanced data processing for source code comments

Re: Coccinelle: semantic patch for missing of_node_put

2019-05-17 Thread Markus Elfring
> 1, A simple method. > We did some experiments, and we could get the list of functions that need to > be considered directly through this script: > > $ spatch --tokens-c drivers/of/base.c 2>&1 | grep "Tag3 " | grep > "of_node_put() on it when done." | awk -F " - " '{print $1}' | grep -o >

Re: Coccinelle: semantic patch for missing of_node_put

2019-05-17 Thread Julia Lawall
A semantic patch has no access to comments. The only thing I can see to do is to use python to interact with some external tools. For example, you could write some code to collect the comments in a file and the lines on which they occur, and then get the comment that most closely precedes the

Re: [Cocci] Coccinelle: semantic patch for missing of_node_put

2019-05-09 Thread Markus Elfring
> It's interesting to get the function list automatically. I occasionally imported code data into list variables or even database tables. > I'll try to parse the drivers/of/base.c file based on comments like this > "* Returns a node pointer with refcount incremented, use > * of_node_put() on it

Re: [Cocci] [PATCH] coccinelle: semantic patch for missing of_node_put

2019-05-08 Thread wen.yang99
Hi Markus, Thanks for the review. > > The call to of_parse_phandle()/of_find_node_by_name() ... returns a node > > pointer with refcount incremented thus it must be explicitly decremented > > after the last usage. > > > > This SmPL is also looking for places where there is an of_node_put on > >

Re: [Cocci] [PATCH] coccinelle: semantic patch for missing of_node_put

2019-05-07 Thread Markus Elfring
> The call to of_parse_phandle()/of_find_node_by_name() ... returns a node > pointer with refcount incremented thus it must be explicitly decremented > after the last usage. > > This SmPL is also looking for places where there is an of_node_put on > some path but not on others. I suggest to

[Cocci] [PATCH] coccinelle: semantic patch for missing of_node_put

2019-05-07 Thread Wen Yang
The call to of_parse_phandle()/of_find_node_by_name() ... returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. This SmPL is also looking for places where there is an of_node_put on some path but not on others. Suggested-by: Julia Lawall

Re: [Cocci] [PATCH] coccinelle: semantic patch for missing of_node_put

2019-03-15 Thread Markus Elfring
> +/// Find missing of_node_put > +/// > +// Confidence: Moderate How much would you like to improve the situation around recurring software development concerns for such source code analysis approaches? > +virtual report > +virtual org I would interpret the provided SmPL code in the way that

Re: [Cocci] [PATCH] coccinelle: semantic patch for missing of_node_put

2019-03-15 Thread Julia Lawall
On Fri, 15 Mar 2019, Wen Yang wrote: > Looking for places where there is an of_node_put on some paths > but not on others. This SmPL checks that there is a put of the > same data elsewhere in the function, so perhaps that will > alleviate the concern about puts where they are not needed, >

[Cocci] [PATCH] coccinelle: semantic patch for missing of_node_put

2019-03-14 Thread Wen Yang
Looking for places where there is an of_node_put on some paths but not on others. This SmPL checks that there is a put of the same data elsewhere in the function, so perhaps that will alleviate the concern about puts where they are not needed, while still making it possible to find the ones that