[Cocci] find lax type usage
avg at icyb.net.ua
Fri Nov 12 14:42:14 CET 2010
on 12/11/2010 15:32 Nicolas Palix said the following:
> Hi Andriy,
> On Fri, Nov 12, 2010 at 2:26 PM, Andriy Gapon <avg at icyb.net.ua> wrote:
>> I wonder if coccinelle can help me with the following issue.
>> There is a type, let's call it sometype_t, that is typedef-ed to int.
>> There is an API which uses that type consistently to provide for possible future
>> extensions. But that there are many lax users of that API which frequently use
>> int instead of sometype_t.
>> For example, sometimes a sometype_t variable is assigned with int value, or
>> conversely a sometype_t value is assigned to int variable, or int value is passed
>> in a function parameter where sometype_t is expected.
>> I wonder if I could use the power of coccinelle to easily find and perhaps even
>> fix such lax type handling.
> Coccinelle should be useful for that purpose, i.e. finding and fixing.
> What kind of sometype_t values do you have ?
> Is it some #define constant ?
No, it's an enum-ish type, more like a bitmask type that can have various values.
> Do you already have the set of fonctions that take a sometype_t parameter
> or should you first find them ?
The number of such functions is quite large, so it's probably better to detect
them. But finding them in advance should also be easily doable.
More information about the Cocci