> Date: Sat, 22 Jul 2017 15:29:17 +0200
> From: Ingo Schwarze <schwa...@usta.de>
> 
> Hi Scott,

> 
> Scott Cheloha wrote on Fri, Jul 21, 2017 at 05:03:11PM -0500:
> 
>> Per encouragement from deraadt@,
> 
> Not sure what exactly he said, but i'm quite sure you misunderstood him.

Okay, going back and rereading, it appears he meant specifically to not
(void) stuff like printf or fprintf, e.g.

        (void)fprintf(stderr, "usage: prog [args]\n");  /* don't do this */

> [...]
> 
> Added to functions like strlcpy(3) where ignoring the return value
> is often a serious bug.  In such a case, (void) is not intended for
> some compiler, but for human consumption.  Its meaning is: This
> call has been carefully audited.  Contrary to the usual situation,
> we can safely ignore the return value here, either because the
> buffer is so large that it can never become full at this point, or
> because truncation is not a problem at this point.
> 
> This cannot be formalized.
> 
> [...]


My (maybe unfounded) concern is that the (void) cast doesn't necessarily
signal the same thing to everyone.  The preponderance of (void) casts
on stuff like memcpy and fprintf seems to confirm this.

But given how context-dependent the casts are, I suppose that trying to
formalize when and when not to employ them would probably be futile.

Reply via email to