On Fri, 1 Mar 2002, Walter Briscoe wrote:
> #ifndef STRICT, an /*@alt void@*/ annotion is applied to the return
> types of fprintf, printf, and sprintf in lib/standard.h.
> Why are other *printf functions (such as vprintf) not so annotated?
This is a judgement call --- our sense was that fprintf and printf are
used so frequently by novice programmers (and nearly all the textbooks and
courses teach them to ignore the result) that they would get too annoyed
if the default library produced warnings for these function calls. It
seems more important for the vprintf, etc. functions seem more important
to check the result since the checking cannot handle the va_list parameter
directly (that is, at least with fprintf, if the parameters don't match
the format codes in a compile-time known string, splint will be able to
produce a warning).
> #if 1, memcpy, memmove and memset are similarly annotated. I was about
> to ask about strcpy but see it is declared as void /*@alt char * @*/...
> I infer that the reason for not using #ifdef STRICT on these is that
> ignoring the return codes does not scrap any information.
> Why are two techniques used for marking void alternatives?
This is just working around limitation in the alt parsing. If we did
char * /*@alt void@*/ it does not parse correctly (the alt could be
interpreted as instead of the * not instead of the char *.
> I would like to alter this standard, default behaviour. How, for
> example, would I allow the return code of fclose to be ignored for a
> particular run of splint? (void)fclose is a bit permanent; -retvalint
> would - presumably - also affect fscanf. A commercial product produces
> message 534 in such cases and allows -esym(534,fclose) to do what I
> want. If my code contains a declaration of fclose which allows a null
> return, I get "Parse Error: Inconsistent function declaration".
> "int foo(); int foo(int bar);" is OK.
> Why not allow "int foo(); int foo /*@alt void@*/();"?
You can do,
extern int /*@alt void@*/ fclose (FILE *) ;
The alt void is part of the return type.