From owner-svn-src-head@freebsd.org Tue Jan 14 08:22:29 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 45A40221649; Tue, 14 Jan 2020 08:22:29 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47xk384YGHz3Jts; Tue, 14 Jan 2020 08:22:28 +0000 (UTC) (envelope-from bapt@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9692B1ABD3; Tue, 14 Jan 2020 08:22:28 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00E8MS8C024517; Tue, 14 Jan 2020 08:22:28 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00E8MS1b024516; Tue, 14 Jan 2020 08:22:28 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <202001140822.00E8MS1b024516@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Tue, 14 Jan 2020 08:22:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356725 - head/usr.bin/diff X-SVN-Group: head X-SVN-Commit-Author: bapt X-SVN-Commit-Paths: head/usr.bin/diff X-SVN-Commit-Revision: 356725 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jan 2020 08:22:29 -0000 Author: bapt Date: Tue Jan 14 08:22:28 2020 New Revision: 356725 URL: https://svnweb.freebsd.org/changeset/base/356725 Log: When system calls indicate an error they return -1, not some arbitrary value < 0. errno is only updated in this case. Obtained from: OpenBSD MFC after: 3 days Modified: head/usr.bin/diff/diff.c head/usr.bin/diff/diffreg.c Modified: head/usr.bin/diff/diff.c ============================================================================== --- head/usr.bin/diff/diff.c Tue Jan 14 08:18:04 2020 (r356724) +++ head/usr.bin/diff/diff.c Tue Jan 14 08:22:28 2020 (r356725) @@ -1,4 +1,4 @@ -/* $OpenBSD: diff.c,v 1.65 2015/12/29 19:04:46 gsoares Exp $ */ +/* $OpenBSD: diff.c,v 1.67 2019/06/28 13:35:00 deraadt Exp $ */ /* * Copyright (c) 2003 Todd C. Miller @@ -316,12 +316,12 @@ main(int argc, char **argv) } else { if (S_ISDIR(stb1.st_mode)) { argv[0] = splice(argv[0], argv[1]); - if (stat(argv[0], &stb1) < 0) + if (stat(argv[0], &stb1) == -1) err(2, "%s", argv[0]); } if (S_ISDIR(stb2.st_mode)) { argv[1] = splice(argv[1], argv[0]); - if (stat(argv[1], &stb2) < 0) + if (stat(argv[1], &stb2) == -1) err(2, "%s", argv[1]); } print_status(diffreg(argv[0], argv[1], dflags, 1), argv[0], Modified: head/usr.bin/diff/diffreg.c ============================================================================== --- head/usr.bin/diff/diffreg.c Tue Jan 14 08:18:04 2020 (r356724) +++ head/usr.bin/diff/diffreg.c Tue Jan 14 08:22:28 2020 (r356725) @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.92 2019/06/28 05:35:34 deraadt Exp $ */ +/* $OpenBSD: diffreg.c,v 1.93 2019/06/28 13:35:00 deraadt Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -277,7 +277,7 @@ diffreg(char *file1, char *file2, int flags, int capsi else { if (!S_ISREG(stb1.st_mode)) { if ((f1 = opentemp(file1)) == NULL || - fstat(fileno(f1), &stb1) < 0) { + fstat(fileno(f1), &stb1) == -1) { warn("%s", file1); status |= 2; goto closem; @@ -298,7 +298,7 @@ diffreg(char *file1, char *file2, int flags, int capsi else { if (!S_ISREG(stb2.st_mode)) { if ((f2 = opentemp(file2)) == NULL || - fstat(fileno(f2), &stb2) < 0) { + fstat(fileno(f2), &stb2) == -1) { warn("%s", file2); status |= 2; goto closem; @@ -446,7 +446,7 @@ opentemp(const char *f) if (strcmp(f, "-") == 0) ifd = STDIN_FILENO; - else if ((ifd = open(f, O_RDONLY, 0644)) < 0) + else if ((ifd = open(f, O_RDONLY, 0644)) == -1) return (NULL); (void)strlcpy(tempfile, _PATH_TMP "/diff.XXXXXXXX", sizeof(tempfile)); @@ -942,7 +942,7 @@ preadline(int fd, size_t rlen, off_t off) ssize_t nr; line = xmalloc(rlen + 1); - if ((nr = pread(fd, line, rlen, off)) < 0) + if ((nr = pread(fd, line, rlen, off)) == -1) err(2, "preadline"); if (nr > 0 && line[nr-1] == '\n') nr--;