[splint-discuss] Variable argument type checking
jhanley at dgtlrift.com
jhanley at dgtlrift.com
Tue Mar 17 06:43:13 PST 2009
Quoting "Hollas Boris (CR/AEY1)" <Boris.Hollas at de.bosch.com>:
> Have you tried using an enum instead of int? E.g.
>
> enum legal_values {0,1,2,3,4,5};
>
>
> > int do_something( int action, ... /* args */ );
> > /* legal ways to call do_something:
> > (void)do_something( 0 );
> > (void)do_something( 1, const char * );
> > (void)do_something( 2, const this_struct_type * );
> > (void)do_something( 3, const that_struct_type * );
> > (void)do_something( 4 );
> > (void)do_something( 5, const this_struct_type *, const >
> that_struct_type * );
I guess my example was a little vague. What I mean to explain is that
the above be in some header file and that when argument one is a value
of 0 or 4, there are no other arguments, when it is a value of 1 the
next should be of type const char *, when it is a value of 2 the next
argument should be of type const this_struct_type *, etc. What I was
hoping for was the ability to annotate to splint as to the legal ways
this function can be called so it can inform the user of the function
if there are any calls that don't match the argument pattern described.
More information about the splint-discuss
mailing list