Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: using "(void)" casts to purposefully ignore return values

On Thu, Sep 01, 2011 at 11:08:46AM +0930, Brett Lymn wrote:
 > > > At least strlcat will tell you that you have
 > > > something wrong if the return value is checked, and that is the crux of
 > > > my objection, why I spoke up in the first place - it is not always ok to
 > > > ignore the returns from strl* because this may rise up and bit you by
 > > > producing a string that is not nul terminated.
 > > 
 > > No, it cannot, unless you pass it an invalid string in the first place.
 > The same could be said of any of the str* functions as has already been
 > stated.

Well right, that's the point.

 > As for strl* the invalid string merely needs to meet the
 > criteria of strlen(dst) > size - dst could be, in other contexts, a
 > valid string.

Sure, but then it's still the same string afterwards, so if it was
valid before it still is, and if it wasn't the behavior of the next
thing you do with it will be just as undefined as it would have been
anyway. So you neither gain nor lose anything.

David A. Holland

Home | Main Index | Thread Index | Old Index