Path: utzoo!attcan!uunet!lll-winken!brutus.cs.uiuc.edu!usc!samsung!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: Discarded Function Values (To Cast or Not to Cast) Message-ID: <11624@smoke.BRL.MIL> Date: 17 Nov 89 15:47:27 GMT References: <316@voa3.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 18 In article <316@voa3.UUCP> ck@voa3.UUCP (Chris Kern) writes: >But what about a standard library function whose value I >(perhaps recklessly) wish to ignore? Should I cast the function >call to void, or am I just indulging in the trivial luxury of >silencing lint? C does not require the (void) cast of the unused return value. As a matter of policy, you shouldn't do things JUST to "shut lint up". Lint is warning you that functions return success status etc. by design and that it may be unwise to fail to check the returned status. Therefore, I would say that for each such warning you should THINK whether or not the returned value is important for the context in which the function is invoked, and if so do something about it, or if not then explicitly discard the value with a (void) cast. If you follow that policy, then the reader of your code will KNOW that (void) means that you've thought about it and decided the return value was not needed. Without the explicit (void) he would have no way to tell if there had been an oversight.