On Thursday 14 January 2010 21:26:40 Julia Lawall wrote:
> I don't know of anyone who has done this.
> 
> I'm not sure about the current feasability of the following:
> 
> - All formerly name __kfifo_* functions has been renamed into kfifo_*
> 
> Nicolas, can it be done with regexps?

Not yet. There is no way to remove the initial "__" or to reuse only
a group defined in the regexp.

However, it should be relatively "easy" to add this feature.
I have planned to do something like:

// First match something
@@
identifier foo ~= "__kfifo_\(.+\)";
@@

// Then, only reuse a sub-part.
// in that case the ".1" mean the 1st group of the foo's regexp.
@@
fresh identifier newfoo = "kfifo_" ## foo.1
@@

Regexp now support groups in the matching part but I haven't added the feature
that allows to reuse matched groups. (See tests/regexp.cocci for what can be
nevertheless done currently)

As a workaround, we can prefix by a MAGIC value, and then use sed 
"s|MAGIC__kfifo|kfifo|"
to remove the MAGIC value and update the original prefix.

> 
> julia
> 
> On Thu, 14 Jan 2010, Németh Márton wrote:
> 
> > Hi,
> > 
> > do anybody know about an SmPL which follows the description
> > in include/linux/kfifo.h ?
> > 
> > >From 
> > >http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=include/linux/kfifo.h
> > > :
> > > /*
> > >  * Howto porting drivers to the new generic fifo API:
> > >  *
> > >  * - Modify the declaration of the "struct kfifo *" object into a
> > >  *   in-place "struct kfifo" object
> > >  * - Init the in-place object with kfifo_alloc() or kfifo_init()
> > >  *   Note: The address of the in-place "struct kfifo" object must be
> > >  *   passed as the first argument to this functions
> > >  * - Replace the use of __kfifo_put into kfifo_in and __kfifo_get
> > >  *   into kfifo_out
> > >  * - Replace the use of kfifo_put into kfifo_in_locked and kfifo_get
> > >  *   into kfifo_out_locked
> > >  *   Note: the spinlock pointer formerly passed to kfifo_init/kfifo_alloc
> > >  *   must be passed now to the kfifo_in_locked and kfifo_out_locked
> > >  *   as the last parameter.
> > >  * - All formerly name __kfifo_* functions has been renamed into kfifo_*
> > >  */
> > 
> > The history can be found here:
> > http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=history;f=include/linux/kfifo.h
> > 
> > Currently I'm facing a problem where a file is compilable with 2.6.33-rc2, 
> > but no
> > longer with 2.6.32 and below because the changes were already applied. I'm 
> > thinking
> > about to revert the changes temporary so the file could be compilable with 
> > 2.6.32.
> > 
> > Regards,
> > 
> >     Márton Németh
> > _______________________________________________
> > Cocci mailing list
> > [email protected]
> > http://lists.diku.dk/mailman/listinfo/cocci
> > (Web access from inside DIKUs LAN only)
> > 

-- 
Nicolas Palix
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to