From owner-svn-src-head@FreeBSD.ORG Sat Oct 8 16:10:38 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ECC2D106566C; Sat, 8 Oct 2011 16:10:38 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail01.syd.optusnet.com.au (mail01.syd.optusnet.com.au [211.29.132.182]) by mx1.freebsd.org (Postfix) with ESMTP id 702038FC15; Sat, 8 Oct 2011 16:10:38 +0000 (UTC) Received: from c122-106-165-191.carlnfd1.nsw.optusnet.com.au (c122-106-165-191.carlnfd1.nsw.optusnet.com.au [122.106.165.191]) by mail01.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p98GAZiY004083 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 9 Oct 2011 03:10:36 +1100 Date: Sun, 9 Oct 2011 03:10:35 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Dag-Erling Smorgrav In-Reply-To: <201110081228.p98CS70F062542@svn.freebsd.org> Message-ID: <20111009030101.Q1307@besplex.bde.org> References: <201110081228.p98CS70F062542@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r226153 - head/usr.bin/kdump X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Oct 2011 16:10:39 -0000 On Sat, 8 Oct 2011, Dag-Erling Smorgrav wrote: > Log: > I appreciate the logic behind using a (void) cast to indicate that the > return value is intentionally ignored, but frankly, all it does is > get in the way of the code. It would be more useful if used precisely when ignoring the return value is correct (and unusual -- never use it for printf()). For example, when printf() is voided, there must be an fflush() and error checking of that at least once in the program (much more often for interactive programs), but most programs that void printf() don't bother with that. kdump was one. It has a single fflush() at the end of main() (which is a reasonable place to put it for simple programs), but only for the -l case, and with null error checking: > Modified: head/usr.bin/kdump/kdump.c > ============================================================================== > --- head/usr.bin/kdump/kdump.c Sat Oct 8 12:27:12 2011 (r226152) > +++ head/usr.bin/kdump/kdump.c Sat Oct 8 12:28:06 2011 (r226153) > @@ -307,7 +307,7 @@ main(int argc, char *argv[]) > break; > } > if (tail) > - (void)fflush(stdout); > + fflush(stdout); > } > return 0; > } Voiding the result of fflush() is just a bug, unless there is an ferror() check, which there isn't. Now this code correctly doesn't claim that ignoring the result is correct. Bruce