Subject: ignoring return values from functions.
To: None <tech-userlevel@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-userlevel
Date: 09/19/2001 11:52:11
Folks,

Currently we don't seem to have a policy on how to ignore return values
for functions.  Even /usr/share/misc/style is inconsistant:

	printf("The size of %s is %lld\n", p, (long long)sb->st_size);
	(void)fprintf(stderr, "usage: %s [-ab]\n", getprogname());

My personal opinion is that using "(void)..." just clutters things
unnecessarily.  I propose adding the trailing diff (is there a better
place to add it?).

Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD CDs, Support and Service:    http://www.wasabisystems.com/


Index: style
===================================================================
RCS file: /cvsroot/sharesrc/share/misc/style,v
retrieving revision 1.18
diff -d -p -u -r1.18 style
--- style	2001/02/21 00:04:43	1.18
+++ style	2001/09/19 01:51:10
@@ -348,6 +348,9 @@ dirinfo(const char *p, struct stat *sb, 
 		err(1, "Unable to stat %s", p);
 
 	/*
+	 * If a function return value is ignored, do not prefix the
+	 * function call with "(void)".
+	 *
 	 * To printf 64 bit quantities, use %ll and cast to (long long).
 	 */
 	printf("The size of %s is %lld\n", p, (long long)sb->st_size);
@@ -395,6 +398,6 @@ usage(void)
 	 * "usage: f [-ade] [-b b_arg] [-m m_arg] req1 req2 [opt1 [opt2]]\n"
 	 * "usage: f [-a | -b] [-c [-de] [-n number]]\n"
 	 */
-	(void)fprintf(stderr, "usage: %s [-ab]\n", getprogname());
+	fprintf(stderr, "usage: %s [-ab]\n", getprogname());
 	exit(1);
 }