[net.unix-wizards] casts to

jdb@mordor.UUCP (John Bruner) (08/08/85)

> > That's a mediocre solution, it shouldn't be necessary lint should know the
> > set of standard functions which results needn't be used. It's not accept-
> > able to either put (void) in front of printf(), scanf(), ...etc. or make
> > defines like "#define Printf (void) printf".
> 
> And programs that do this don't recover from write errors, like when a
> filesystem runs out of space.  That's what lint *correctly* complains about.

For instance, the "passwd" program, which, when copying "passwd"
to "ptmp", will blissfully truncate the password file if the root
filesystem is out of space.  This problem has been around since (at
least) V6 and STILL isn't fixed in either 4.2BSD or System V.  (The
4.2BSD "passwd" program doesn't bother to cast fprintf(), which the
manual page doesn't document as returning a value anyway.  In System V,
"passwd" calls putpwent(), which does check for an error and returns
an error indication.  Unfortunately, "passwd" doesn't bother to check
(or cast to (void)) the return value from putpwent().)
--
  John Bruner (S-1 Project, Lawrence Livermore National Laboratory)
  MILNET: jdb@mordor [jdb@s1-c.ARPA]	(415) 422-0758
  UUCP: ...!ucbvax!dual!mordor!jdb 	...!seismo!mordor!jdb
-- 
  John Bruner (S-1 Project, Lawrence Livermore National Laboratory)
  MILNET: jdb@mordor [jdb@s1-c.ARPA]	(415) 422-0758
  UUCP: ...!ucbvax!dual!mordor!jdb 	...!seismo!mordor!jdb

peter@kitty.UUCP (Peter DaSilva) (08/09/85)

> > That's a mediocre solution, it shouldn't be necessary lint should know the
> > set of standard functions which results needn't be used. It's not accept-
> > able to either put (void) in front of printf(), scanf(), ...etc. or make
> > defines like "#define Printf (void) printf".
> 
> And programs that do this don't recover from write errors, like when a
> filesystem runs out of space.  That's what lint *correctly* complains about.

OK. How about

	Printf(fmt,a,b,c,d,e,f,g,h,i,j,k,l) { assert(printf(fmt,...)!=FAIL); }