From owner-svn-src-all@FreeBSD.ORG Fri May 24 18:54:52 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C9416A8A; Fri, 24 May 2013 18:54:52 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id B9E5598F; Fri, 24 May 2013 18:54:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4OIsq1b043688; Fri, 24 May 2013 18:54:52 GMT (envelope-from se@svn.freebsd.org) Received: (from se@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4OIsqdU043683; Fri, 24 May 2013 18:54:52 GMT (envelope-from se@svn.freebsd.org) Message-Id: <201305241854.r4OIsqdU043683@svn.freebsd.org> From: Stefan Esser Date: Fri, 24 May 2013 18:54:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r250972 - head/usr.bin/patch 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.14 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: Fri, 24 May 2013 18:54:52 -0000 Author: se Date: Fri May 24 18:54:52 2013 New Revision: 250972 URL: http://svnweb.freebsd.org/changeset/base/250972 Log: The error handling for writes to the target file could lead to the final fclose() being skipped. Fix this by using boolean "&" and "|" instead of short-cut operators "&&" and "||". While here, increment the last part of the version string. The reason is the fixed output file selection logic in pch.c, which was committed as r250943, yesterday. Reviewed by: pfg Modified: head/usr.bin/patch/patch.c head/usr.bin/patch/util.c Modified: head/usr.bin/patch/patch.c ============================================================================== --- head/usr.bin/patch/patch.c Fri May 24 18:28:27 2013 (r250971) +++ head/usr.bin/patch/patch.c Fri May 24 18:54:52 2013 (r250972) @@ -303,7 +303,7 @@ main(int argc, char *argv[]) ++fuzz <= mymaxfuzz); if (skip_rest_of_patch) { /* just got decided */ - if (ferror(ofp) || fclose(ofp)) { + if (ferror(ofp) | fclose(ofp)) { say("Error writing %s\n", TMPOUTNAME); error = 1; @@ -385,7 +385,7 @@ main(int argc, char *argv[]) } } } - if (ferror(rejfp) || fclose(rejfp)) { + if (ferror(rejfp) | fclose(rejfp)) { say("Error writing %s\n", rejname); error = 1; } @@ -977,7 +977,7 @@ spew_output(void) #endif if (input_lines) copy_till(input_lines, true); /* dump remainder of file */ - rv = ferror(ofp) == 0 && fclose(ofp) == 0; + rv = ferror(ofp) == 0 & fclose(ofp) == 0; ofp = NULL; return rv; } Modified: head/usr.bin/patch/util.c ============================================================================== --- head/usr.bin/patch/util.c Fri May 24 18:28:27 2013 (r250971) +++ head/usr.bin/patch/util.c Fri May 24 18:54:52 2013 (r250972) @@ -412,7 +412,7 @@ checked_in(char *file) void version(void) { - fprintf(stderr, "patch 2.0-12u8 FreeBSD\n"); + fprintf(stderr, "patch 2.0-12u9 FreeBSD\n"); my_exit(EXIT_SUCCESS); }