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
>(Str.regexp "[a-zA-Z_\\(\\)][-a-zA-Z0-9_\\(\\)]*$")
>  x 0) (Str.split (Str.regexp "[ .;\t\n]+") c in

I would interpret one of these function calls in the way
that text splitting is performed here also for space characters
after a concatenation was performed.


>  Printf.printf "comments: %s\n" s;
>  if contains s relevant_str
>  then
>Printf.printf "Found relevant function: %s\n" f;
>relevant_functions := f :: !relevant_functions;
>   end
>
> @r@
> identifier fn;
> comments c;
> type T = struct device_node *;
> @@
>
> T@c fn(...) {
> ...
> }
>
> @script:ocaml@
> f << r.fn;
> c << r.c;
> @@
>
> let (cb,cm,ca) = List.hd c in
> let c = String.concat " " cb in
> add_function f c

Can an other data processing variant be more reasonable?

Regards,
Markus


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 you like to keep this adjustment approach (for a while)?

* Will other data structures become nicer for the discussed data extraction?


> so we can exactly match the target string 'use of_node_put() on it when done '

Thanks for this clarification.

Regards,
Markus


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 distributed over text lines in the discussed
> software documentation.
> 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, so we can exactly match the target string
'use of_node_put() on it when done '

--
Regards,
Wen___
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci