From f37b8c3d9fd70486ee2946d794f5d2ac36ef4e43 Mon Sep 17 00:00:00 2001 From: rlar Date: Tue, 13 Feb 2018 18:19:44 +0100 Subject: [PATCH] DEVdelete(), change API, #1/2, klag-1.cocci for coccinelle --- klag-1.cocci | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 klag-1.cocci diff --git a/klag-1.cocci b/klag-1.cocci new file mode 100644 index 000000000..9f937bc1c --- /dev/null +++ b/klag-1.cocci @@ -0,0 +1,61 @@ +// DEVdelete() change API +// drop instance and model search loop +// don't FREE the instance struct +// +// (compile "git grep -l -e 'delete' -- '*.[ch]' | xargs -P8 -n1 spatch --sp-file klag-1.cocci --in-place && git commit -am 'DEVdelete(), change API, #1/2, coccinelle semantic patch'") +// +// (compile "spatch --sp-file klag-1.cocci src/spicelib/devices/bjt/*.[ch]") +// (compile "spatch --sp-file klag-1.cocci src/spicelib/devices/asrc/asrcdel.c") +// (compile "spatch --sp-file klag-1.cocci src/spicelib/devices/bsim1/b1del.c") +// (compile "spatch --sp-file klag-1.cocci src/xspice/mif/mifdelete.c") + + +@unify_DEVdelete@ +identifier fn =~ "delete$"; +typedef GENmodel, IFuid, GENinstance; +identifier XinModel, Xname, Xkill; +type Tm, Ti; +identifier Xprev, Xhere, Xmod, Xinst; +identifier XXXnextModel, XXXinstances, XXXnextInstance, XXXname; +symbol OK, E_NODEV; +@@ + int fn ( +- GENmodel *XinModel , IFuid Xname , GENinstance **Xkill ++ GENinstance *gen_inst + ) + { +( +- Ti **Xinst = (Ti **) Xkill; +- Tm *Xmod = (Tm *) XinModel; +| +- Tm *Xmod = (Tm *) XinModel; +- Ti **Xinst = (Ti **) Xkill; +) +- Ti **Xprev = NULL; +- Ti *Xhere; +- for (; Xmod; Xmod = Xmod->XXXnextModel) { +- Xprev = &(Xmod->XXXinstances); +- for (Xhere = *Xprev; Xhere; Xhere = *Xprev) { +- if (Xhere->XXXname == Xname || (Xinst && Xhere == *Xinst)) { +- *Xprev = Xhere->XXXnextInstance; +- FREE(Xhere); +- return(OK); +- } +- Xprev = &(Xhere->XXXnextInstance); +- } +- } +- return(E_NODEV); ++ NG_IGNORE(gen_inst); ++ return OK; + } + + +@unify_DEVdelete_h@ +identifier fn =~ "delete$"; +typedef GENmodel, IFuid, GENinstance; +@@ + extern int fn ( +- GENmodel *, IFuid, GENinstance * ++ GENinstance + * + );