Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Mar 2002 06:38:41 -0500
From:      Mike Barcroft <mike@FreeBSD.ORG>
To:        Harti Brandt <brandt@fokus.gmd.de>
Cc:        "David O'Brien" <obrien@FreeBSD.ORG>, Mark Murray <markm@FreeBSD.ORG>, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG
Subject:   Re: cvs commit: src/usr.bin/rwall rwall.c
Message-ID:  <20020307063841.D81803@espresso.q9media.com>
In-Reply-To: <20020307121629.J99061-100000@beagle.fokus.gmd.de>; from brandt@fokus.gmd.de on Thu, Mar 07, 2002 at 12:21:59PM %2B0100
References:  <20020307060920.C81803@espresso.q9media.com> <20020307121629.J99061-100000@beagle.fokus.gmd.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Harti Brandt <brandt@fokus.gmd.de> writes:
> The point of (void) is that the programmer who writes the code tells
> another programmer who reads the code: "Yes, I know, this function returns
> a value, but I ignore it and I know what I'm doing so don't be surprised."

I always thought that explanation was rather silly.  Why not just put
a comment at the top that says, "I realize I don't check every return
value, that is intentional." :)

I did find the explanation I was looking for in
Message-ID: <20010817005031.S29341-100000@besplex.bde.org>:
: 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"
:
: This is the opposite of getting in the way of linting.

> In the given case it is obvious that the snprintf shouldn't fail.

In this case yes, in general snprintf()'s return value should always
be checked unless truncation is irrelevant.  For cases in which
snprintf() can't fail, sprintf() is a good choice.

Best regards,
Mike Barcroft

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




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