Path: utzoo!attcan!uunet!lll-winken!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: lint question Message-ID: <9322@smoke.BRL.MIL> Date: 10 Jan 89 02:33:15 GMT References: <491@babbage.acc.virginia.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 20 In article <491@babbage.acc.virginia.edu> pts@watt.acc.Virginia.EDU (Paul T. Shannon) writes: >function returns value which is always ignored > fprintf printf >Is it bad style to use these functions without also checking the >returned value? Since these functions can, and at times do, fail, in a robust program you should indeed test their return values and take proper error- recovery actions. The one possible exception is (void)fprintf(stderr, "...: operation failed\n"); because if a write to the standard error output fails, you may have just exhausted your error-recovery resources and can do no better anyway. (What are you going to do, complain about THAT failure on stderr?) Note the use of a (void) cast to explicitly discard an unused function value. This should not be done lightly; if properly used, it indicates that the programmer realized that the function returns a value but that it is not necessary in this particular instance to use the value. This will shut lint up, but that should not be the prime motivation for using the cast!