Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Aug 2001 16:51:20 +0100
From:      Mark Murray <mark@grondar.za>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        arch@FreeBSD.ORG
Subject:   Re: Style 9 nitpicking question 
Message-ID:  <200108161551.f7GFpLK72129@grimreaper.grondar.za>
In-Reply-To: <20010817005031.S29341-100000@besplex.bde.org> ; from Bruce Evans <bde@zeta.org.au>  "Fri, 17 Aug 2001 01:16:37 %2B1000."
References:  <20010817005031.S29341-100000@besplex.bde.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> > Questions:
> >
> > 1) That "(void)" is useless by any metric that I am able to determine
> >    (WARNS=2, BDECFLAGS etc), and gets in the way of linting. Is there
> >    any reason to continue to advocate its use by this example? There
> >    is no other reference to "voiding-out" of return values.
> 
> It by prevents warnings like the following from `lint -h':
> 
>     "snprintf returns a value which is sometimes ignored"
>     "snprintf returns a value which is always ignored"

Hmm - in the linting that I have done, I've told lint that ignoring
the return value of ${THESE} functions is OK.

(THESE = str* *printf, *scanf and a few others)

> This is the opposite of getting in the way of linting.

Sorta :-) Its often not a useful warning (most particularly for
certain functions), and the (void) cast offends me because it is
useless and obfuscating.

> > 2) Is this (fprintf(stderr, "...", ...); exit(n);) really better than
> >    errx(1, "...", ...); ?
> 
> Yes.  The former is more portable, and prints the program name in the
> usual place (after "usage: ").

OK.

> > Any objections to changing the
> >
> > 	(void)fprintf(stderr, "usage: f [-ab]\n");
> > 	exit(EX_USAGE);
> >
> > to
> >
> > 	errx(EX_USAGE, "usage: f [-ab]\n");
> 
> Yes :-).  The second form here has the additional bug of printing the
> program name twice (perhaps different names if the binary is linked).

OK.

M
-- 
Mark Murray
Warning: this .sig is umop ap!sdn

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108161551.f7GFpLK72129>