Re: [cocci] Searching for duplicate exception handling code with SmPL?
Julia Lawall <[email protected]> Sat, 13 Jun 2026 19:42:27 +0200 (CEST)
| Newsgroups | fr.inria.cocci |
|---|---|
| Message-ID | <[email protected]> |
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1308786606-1781372547=:28904 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Sat, 13 Jun 2026, Markus Elfring wrote: > >> Is there a field or column like incidence desirable? > > Do you agree that my semantic patch finds what you expect to find? > > Your SmPL script variant looks promising. > > // See also: > // https://lore.kernel.org/cocci/[email protected]/ > // https://sympa.inria.fr/sympa/arc/cocci/2026-06/msg00005.html > @searching_for_OCaml@ > expression e, x; > identifier item, rc; > position p1, p2; > @@ > if (...) > { > ... when != rc = e > when != item = x > kfree@p1(item); > return rc; > } > ... when any > if (...) > { > ... when != rc = e > when != item = x > kfree@p2(item); > return rc; > } > > @script:ocaml@ > p1 << searching_for_OCaml.p1; > p2 << searching_for_OCaml.p2; > @@ > Printf.eprintf "duplicate on lines %d and %d\n" (List.hd p1).line (List.hd p2).line > > > Questionable test result on my development system: > Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> /usr/bin/spatch …/Projekte/Coccinelle/janitor/show_duplicate_statements_in_if_branches3.cocci sound/core/seq/seq_fifo.c > … > Using native version of ocamlc/ocamlopt/ocamldep > ocamlopt.opt -shared -o /tmp/ocaml_cocci_ad6bde.cmxs -g -I /usr/lib64/coccinelle/ocaml -I /home/Markus_Elfring/.opam/5.3.0/lib64 -for-pack Coccinelle_modules /tmp/ocaml_cocci_ad6bde.ml > File "/tmp/ocaml_cocci_ad6bde.ml", line 1: > Error: /usr/lib64/coccinelle/ocaml/coccilib.cmi > is not a compiled interface for this version of OCaml. > It seems to be for an older version of OCaml. > Fatal error: exception Coccinelle_modules.Yes_prepare_ocamlcocci.CompileFailure("/tmp/ocaml_cocci_ad6bde.ml") OK, so write the codein python. It should be clear in any case what it does. > > If you agree on that, > > I would appreciate if an intended data output can be reproduced finally. > > But which software functionality would perform counting of repeated items > in your data processing approach? I did't count anything. Since I don't know what you code does, nor what it is intended to do, I didn't bother trying to reproduce it. Can't you just explain what you hoped would happen and whythe result is not what you expected? julia > > > > it would seem that the problem is in your python code. > > Some communication challenges were presented. > > Regards, > Markus > --8323329-1308786606-1781372547=:28904--