Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 exptools; site laidbak.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!lll-crg!dual!qantel!ihnp4!laidbak!mark From: mark@laidbak.UUCP (Mark Brukhartz) Newsgroups: net.lang.c Subject: Re: (void) and printf Message-ID: <152@laidbak.UUCP> Date: Wed, 7-Aug-85 04:37:23 EDT Article-I.D.: laidbak.152 Posted: Wed Aug 7 04:37:23 1985 Date-Received: Mon, 12-Aug-85 00:54:50 EDT References: <431@brl-tgr.ARPA> Organization: LAI Chicago Lines: 39 > Granted, there are occasions when you want to test the return values > of the I/O functions. But if you think (void) printf() is bad, how > about: > > (void) sprintf(str,"foo"); > > How often does sprintf() return an error indication on YOUR system? > > Gary It appears that sprintf() comes in several flavors: o System V (...chocolate) returns the length of the generated string. o 4.2BSD (...strawberry) returns a pointer to the generated string. o Version 7 (...vanilla) does not document a return value. Lint should certainly complain about ignored return values from functions which might fail, such as read(), write() and printf(). Some other functions, like getlogin(), serve no obvious purpose when their return values are ignored. Thus, they should also be watched closely by lint. Many functions manipulate data via pointers or global variables, returning convenient values for nesting purposes; strcpy() and strcat() come to mind. It is safe (and quite commonplace) to ignore the return value from such a function. We could make lint recognize (yet another) "special comment" to shut off "ignored return value" complaints for a given function. For example, "/* MAYIGNORE */" before a function definition (or lint library function definition stub) could stop complaints of ignored return value on *all* calls to the given function. Given that (void) casts should still be required with printf(), since it can truly fail, is this problem really worthy of another lint "special comment"? Mark Brukhartz ..!ihnp4!laidbak!mark