Subject: Re: bin/7592: programs' error handle broken by good intentions
To: None <gnats-bugs@gnats.netbsd.org,>
From: Greg A. Woods <woods@most.weird.com>
List: netbsd-bugs
Date: 05/19/1999 22:14:34
[ On , May 17, 1999 at 06:05:44 (-0000), cgd@netbsd.org wrote: ]
> Subject: bin/7592: programs' error handle broken by good intentions
>
> 	68 [speedy] log % mount -t cd9660 foo bar
> 	mount_cd9660: : No such file or directory

At first I thought you were only going to complain about these totally
unacceptably misleading and somewhat meaningless error messages printed
by the "mount" family of commands!  ;-)  I think that's already been
commented on in another PR....

> 	This code is broken.  To do what it is trying to do, the correct
> 	invocation of err() is:
> 
> 		err(1, NULL);

I'd prefer to see people write:

		err(1, (const char *) NULL);

I.e. I'd like to see "CFLAGS+= -Wconversion" always used in bsd.sys.mk
as well, and that the hackish special treatment of '0' be eliminated.
(I.e. the fact that when you pass 0 it is silently co-erced by the
prototype, but if you pass 1 you'll get the warning "passing arg 2 of
`err' makes pointer from integer without a cast".)

I fully realize that ANSI C doesn't *require* such practices, but so far
as I can tell it certainly doesn't prohibit them either and since this
is entirely about writing code that's easy to read and understand 

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>