From owner-svn-src-all@freebsd.org Thu Aug 25 17:13:05 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA781BC6534; Thu, 25 Aug 2016 17:13:05 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 95E0A1F05; Thu, 25 Aug 2016 17:13:05 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u7PHD41E069871; Thu, 25 Aug 2016 17:13:04 GMT (envelope-from ache@FreeBSD.org) Received: (from ache@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u7PHD4jr069868; Thu, 25 Aug 2016 17:13:04 GMT (envelope-from ache@FreeBSD.org) Message-Id: <201608251713.u7PHD4jr069868@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ache set sender to ache@FreeBSD.org using -f From: "Andrey A. Chernov" Date: Thu, 25 Aug 2016 17:13:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r304810 - head/lib/libc/stdio X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Aug 2016 17:13:05 -0000 Author: ache Date: Thu Aug 25 17:13:04 2016 New Revision: 304810 URL: https://svnweb.freebsd.org/changeset/base/304810 Log: Don't check for __SERR which may stick from one of any previous stdio functions. __SERR is for user and the rest of stdio code do not check it for error sensing internally, only set it. In vf(w)printf.c here it is more easy to save __SERR, clear and restore it. Modified: head/lib/libc/stdio/getdelim.c head/lib/libc/stdio/vfprintf.c head/lib/libc/stdio/vfwprintf.c Modified: head/lib/libc/stdio/getdelim.c ============================================================================== --- head/lib/libc/stdio/getdelim.c Thu Aug 25 17:07:43 2016 (r304809) +++ head/lib/libc/stdio/getdelim.c Thu Aug 25 17:13:04 2016 (r304810) @@ -125,7 +125,7 @@ getdelim(char ** __restrict linep, size_ if (fp->_r <= 0 && __srefill(fp)) { /* If fp is at EOF already, we just need space for the NUL. */ - if (__sferror(fp) || expandtofit(linep, 1, linecapp)) + if (!__sfeof(fp) || expandtofit(linep, 1, linecapp)) goto error; FUNLOCKFILE(fp); (*linep)[0] = '\0'; @@ -137,7 +137,7 @@ getdelim(char ** __restrict linep, size_ if (sappend(linep, &linelen, linecapp, fp->_p, fp->_r)) goto error; if (__srefill(fp)) { - if (__sferror(fp)) + if (!__sfeof(fp)) goto error; goto done; /* hit EOF */ } Modified: head/lib/libc/stdio/vfprintf.c ============================================================================== --- head/lib/libc/stdio/vfprintf.c Thu Aug 25 17:07:43 2016 (r304809) +++ head/lib/libc/stdio/vfprintf.c Thu Aug 25 17:13:04 2016 (r304810) @@ -364,6 +364,7 @@ __vfprintf(FILE *fp, locale_t locale, co int nextarg; /* 1-based argument index */ va_list orgap; /* original argument pointer */ char *convbuf; /* wide to multibyte conversion result */ + int savserr; static const char xdigs_lower[16] = "0123456789abcdef"; static const char xdigs_upper[16] = "0123456789ABCDEF"; @@ -460,6 +461,9 @@ __vfprintf(FILE *fp, locale_t locale, co return (EOF); } + savserr = fp->_flags & __SERR; + fp->_flags &= ~__SERR; + convbuf = NULL; fmt = (char *)fmt0; argtable = NULL; @@ -1031,6 +1035,8 @@ error: free(convbuf); if (__sferror(fp)) ret = EOF; + else + fp->_flags |= savserr; if ((argtable != NULL) && (argtable != statargtable)) free (argtable); return (ret); Modified: head/lib/libc/stdio/vfwprintf.c ============================================================================== --- head/lib/libc/stdio/vfwprintf.c Thu Aug 25 17:07:43 2016 (r304809) +++ head/lib/libc/stdio/vfwprintf.c Thu Aug 25 17:13:04 2016 (r304810) @@ -444,6 +444,7 @@ __vfwprintf(FILE *fp, locale_t locale, c int nextarg; /* 1-based argument index */ va_list orgap; /* original argument pointer */ wchar_t *convbuf; /* multibyte to wide conversion result */ + int savserr; static const char xdigs_lower[16] = "0123456789abcdef"; static const char xdigs_upper[16] = "0123456789ABCDEF"; @@ -536,6 +537,9 @@ __vfwprintf(FILE *fp, locale_t locale, c return (EOF); } + savserr = fp->_flags & __SERR; + fp->_flags &= ~__SERR; + convbuf = NULL; fmt = (wchar_t *)fmt0; argtable = NULL; @@ -1096,6 +1100,8 @@ error: free(convbuf); if (__sferror(fp)) ret = EOF; + else + fp->_flags |= savserr; if ((argtable != NULL) && (argtable != statargtable)) free (argtable); return (ret);