Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Mar 2016 13:01:54 +0300
From:      Andrey Chernov <ache@freebsd.org>
To:        "Pedro F. Giffuni" <pfg@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r297408 - head/lib/libc/stdio
Message-ID:  <56FBA412.5010301@freebsd.org>
In-Reply-To: <201603300613.u2U6DwGv026746@repo.freebsd.org>
References:  <201603300613.u2U6DwGv026746@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 30.03.2016 9:13, Pedro F. Giffuni wrote:
>  	 */
> +	sverrno = 0;
>  	if (file == NULL) {

It introduces the bug of touching errno. Previous code does it right
because 'goto finish;' can't happen with (f < 0) where errno is restored
later.

The whole errno code is complex here for reading at least.
It microoptimize errno handling by removing unnecessary assignment, but
it does not gain much in reality.

Better change for easy reading will be to set
sverrno = errno;
once right at the function enter and remove it in all other places.

In any case errno touching should be backed out.

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



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