Re: cocci: multiple versions of function with different arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Wed, 23 Apr 2014, Stefan Assmann wrote:

> On 23.04.2014 12:41, Johannes Berg wrote:
> > On Wed, 2014-04-23 at 12:27 +0200, Stefan Assmann wrote:
> >
> >> I'm trying to generate a patch to define a function with different
> >> arguments depending on the kernel version. I'm having some difficulties,
> >> maybe you can tell me what's wrong with the following approach.
> >
> > I can't answer that, but given the premise
> >
> >> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
> >>         vlan_rx_add_vid_func(a, b, c)
> >> +#else
> >> +       vlan_rx_add_vid_func(a, c)
> >> +#endif
> >
> > and the fact that later kernel versions add an argument, wouldn't it be
> > much easier to provide a macro in the appropriate header file:
> >
> > #define vlan_rx_add_vid_func(a,b,c) vlan_rx_add_vid_func(a,c)
> >
> > johannes
> >
>
> That's one way to handle it but I'm sure there will be other cases where
> we might use coccinelle similarly, where a define might be tricky.
> Luis asked me to do some cleanup on igb, so I'm exploring ways to make
> it easier for other network drivers as well.
>
> If for some reason cocci should have a problem with this the fallback
> to a define is a good idea.
>
> Thanks Johannes!

I think that the problem is that the SmPL parser doesn't really understand
about the ifdef.  So it sees one expression right after another one, which
it is not happy about.  It would be fine if there were semicolons after
the function call.  If you can move up to the statement level in each
possible case, that might be a solution, but it might be too awkward in
practice.  If the macro solution is feasible, that could be better.  Fewer
changes to the source code as well.

julia
--
To unsubscribe from this list: send the line "unsubscribe backports" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux