svn commit: r236582 - head/lib/libc/stdlib

Andrey Chernov ache at FreeBSD.ORG
Tue Jun 5 14:31:18 UTC 2012


On Tue, Jun 05, 2012 at 04:25:10PM +0200, Joerg Sonnenberger wrote:
> > Please see 
> > http://austingroupbugs.net/view.php?id=385
> 
> That is about explicitly recognizing how stupid the notion of free(3)
> not preserving errno is. Seriously, before you start to randomly bloat
> code all over the place, restricting the behavior of free(3) to be
> sensible is a much saner option.

I agree that saving errno inside free() itself will make life easy, 
but I just follow their recommendation:

"However, earlier versions of this standard did not require this, and the
same example had to be written as:

    // buf was obtained by malloc(buflen)
    ret = write(fd, buf, buflen);
    if (ret < 0) {
        int save = errno;
        free(buf);
        errno = save;
        return ret;
    }
"

All we have now is "earlier version of this standard". Until they'll 
publish the future version, we can't ignore the recommendation.

BTW, if general consensus will be to track unpublished standard, I will 
back out my change (in hope our malloc() maintainer will change free() to 
directly save errno).

-- 
http://ache.vniz.net/


More information about the svn-src-all mailing list