[Cocci] Unmatching rule

Jan Kara jack at suse.cz
Mon Dec 1 20:21:33 CET 2014


  Hello,

  I was doing some conversion using coccinelle using the attached script
and I'm wondering why the rule unreg2 doesn't match anywhere in linux
kernel in drivers/media/dvb-core/dvbdev.c. Can someone explain to me
what am I doing wrong? Thanks!

								Honza

-- 
Jan Kara <jack at suse.cz>
SUSE Labs, CR
-------------- next part --------------
@decl@
identifier x;
@@
-static struct cdev x;

@initadd@
identifier decl.x;
expression fops;
identifier ret;
expression d;
expression count;
statement stmt;
@@
-	cdev_init(&x, fops);
(
-	ret = cdev_add(&x, d, count);
-	if (<+...ret...+>) stmt
|
-	if (<+...cdev_add(&x, d, count)...+>) stmt
)

@creationdyn@
identifier d;
identifier ret;
identifier major;
expression initadd.fops;
expression name;
expression initadd.count;
expression first_minor;
@@
-	dev_t d;
...
-	ret = alloc_chrdev_region(&d, first_minor, count, name);
+	ret = __register_chrdev(0, first_minor, count, name, fops);
...
-	major = MAJOR(d);
+	major = ret;

@creationstat@
identifier d;
identifier ret;
expression major;
expression initadd.fops;
expression name;
expression initadd.count;
expression first_minor;
statement stmt;
@@
-	dev_t d = MKDEV(major, first_minor);
...
(
-	ret = register_chrdev_region(d, count, name);
+	ret = __register_chrdev(major, first_minor, count, name, fops);
|
-	if (<+...ret = register_chrdev_region(d, count, name)...+>) stmt
+	ret = __register_chrdev(major, first_minor, count, name, fops);
+	if (ret) stmt
)

@deletion@
identifier decl.x;
@@
-	cdev_del(&x);

@unreg@
identifier d;
expression count;
expression major, minor;
expression creationstat.name;
@@
-	dev_t d = MKDEV(major, minor);
	...
-	unregister_chrdev_region(d, count);
+	__unregister_chrdev(major, minor, count, name);

@unreg2@
expression d;
expression count;
expression creationstat.major, creationstat.first_minor;
expression creationstat.name;
@@
-	unregister_chrdev_region(d, count);
+	__unregister_chrdev(major, first_minor, count, name);


More information about the Cocci mailing list