We have a variadic function whose prototype looke like:
typedef enum msg_e_tag {
MSG_FORMAT_FOO,
MSG_FORMAT_BAR,
MSG_FORMAT_LALA,
MSG_FORMAT_LAST
} msg_e_type;
status_type msg_send( msg_e_type t, ... /* args */ );
The msg_send function and the msg_e_type are defined by a script which uses a message description file, which has hundreds of combinations of parameters. The generated function packs and sends the message using the arguments provided by the user based on the value of t. What we would like to see is the ability to check the validity of data types passed into the msg_send function based on the value of t.
something like:
status_type msg_send( msg_e_type t, ... /* args */ );
/*@variadic t:=
MSG_FORMAT_FOO,char *, char *;
MSG_FORMAT_BAR,mystruct_type *, long, void *;
MSG_FORMAT_LALA,someother_type *;
MSG_FORMAT_LAST; */
This way if a user attempted:
someother_type wrong_var;
long notTheAddress;
msg_send( MSG_FORMAT_BAR, &wrong_var, ¬TheAddress );
Splint would spit out that they are using the wrong types in argument 2 and 3 (and what was expected), and that argument 4 is missing, because argument 1 is set to MSG_FORMAT_BAR.
If this is already available by some other means (like extensible checking), I would really like to know the details of how to do this level of checking.