All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] Unmatching rule
@ 2014-12-01 19:21 Jan Kara
  2014-12-01 19:26 ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2014-12-01 19:21 UTC (permalink / raw)
  To: cocci

  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@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);

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

* [Cocci] Unmatching rule
  2014-12-01 19:21 [Cocci] Unmatching rule Jan Kara
@ 2014-12-01 19:26 ` Jan Kara
  2014-12-01 20:43   ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2014-12-01 19:26 UTC (permalink / raw)
  To: cocci

On Mon 01-12-14 20:21:33, Jan Kara wrote:
>   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!
  Ah, I figured it out a moment after I sent this email. The prerequisite
rule wasn't matching and I missed that when looking at the generated diff.

								Honza

> -- 
> Jan Kara <jack@suse.cz>
> SUSE Labs, CR

> @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);

-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

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

* [Cocci] Unmatching rule
  2014-12-01 19:26 ` Jan Kara
@ 2014-12-01 20:43   ` Julia Lawall
  0 siblings, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2014-12-01 20:43 UTC (permalink / raw)
  To: cocci

On Mon, 1 Dec 2014, Jan Kara wrote:

> On Mon 01-12-14 20:21:33, Jan Kara wrote:
> >   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!
>   Ah, I figured it out a moment after I sent this email. The prerequisite
> rule wasn't matching and I missed that when looking at the generated diff.

Good to have problems solved so quickly :)

julia

> 
> 								Honza
> 
> > -- 
> > Jan Kara <jack@suse.cz>
> > SUSE Labs, CR
> 
> > @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);
> 
> -- 
> Jan Kara <jack@suse.cz>
> SUSE Labs, CR
> _______________________________________________
> Cocci mailing list
> Cocci at systeme.lip6.fr
> https://systeme.lip6.fr/mailman/listinfo/cocci
> 

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

end of thread, other threads:[~2014-12-01 20:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-01 19:21 [Cocci] Unmatching rule Jan Kara
2014-12-01 19:26 ` Jan Kara
2014-12-01 20:43   ` Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.