Coccinelle Archive on lore.kernel.org
 help / color / Atom feed
* [Cocci] qualified function rule
@ 2021-01-27 20:23 James K. Lowden
  2021-01-27 20:35 ` Julia Lawall
  2021-01-30  3:53 ` Mansour Moufid
  0 siblings, 2 replies; 3+ messages in thread
From: James K. Lowden @ 2021-01-27 20:23 UTC (permalink / raw)
  To: cocci

I don't understand how, if it's possible, to qualify a function in a
rule.  I want the class of all functions having a parameter of a
particular type. 

The code I'm working with has hundreds of unnecessary casts.  Many
functions take a void* parameter, but are nonetheless called by casting
the parameter.  For example, the parameters to memcpy(3) often
have casts applied.  

I imagine writing a rule like

@@
type T, D;
identifier F(void*);
identifier D * data;
@@

- F((T*)data)
+ F(data)

but that doesn't work, and I haven't found anything that does.  

In the kmalloc examples, I see things like 

- \(kmalloc|kcmalloc\)(...)
+ mumble something

but that forces me to enumerate all such function names. It seems
vaguely like positions would do the trick, but, well, vaguely.  

Is there a way?  

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

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-27 20:23 [Cocci] qualified function rule James K. Lowden
2021-01-27 20:35 ` Julia Lawall
2021-01-30  3:53 ` Mansour Moufid

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
	public-inbox-index cocci

Example config snippet for mirrors

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.git