From owner-svn-src-head@freebsd.org Tue Jan 14 15:44:34 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 7C4801EEF8B for ; Tue, 14 Jan 2020 15:44:34 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound2m.ore.mailhop.org (outbound2m.ore.mailhop.org [54.149.155.156]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47xvsG0hJpz4JFH for ; Tue, 14 Jan 2020 15:44:33 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1579016672; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=ttvMjIIRe5uf+GtpH08Jh/PHJLjyoFDhDleMduEQ09jAtMKVcDNate+ENF3ZweiNneeuEwChol8Om A2v6+Hyh4fkWwpcfGLssYVhzskTk/awRbAzKWv3O00xQ26KBmtZJlfRI3UzqqayLIj02PAjA6EppSe 7tGPJmwbzwUam+XoabPdwHJn113NFhqXLQ01lOFDfw6o4eCkkxW1ng5suowElRDuCNc53DBNDULxxJ iPg8+XBU/jbuL6M3c5SO0SBP3/Aa1h4ndiaa32KO8289ql2or11KEMO11gMT37oEmQHH89Kyhak6gE 8tbXzPaAudsNHzzvntELpq41JrHbz9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:dkim-signature:from; bh=uWPU/ke/yRe+PaTbSqTFMOy7e1Jcz6ml0LKeETUDQiw=; b=bFdL+AZx29IzzKZ5R/aMlrl7GvSzpd/67fL34IqrcZLQKo4/59TK1fdcwXXDN9NJoCnGEGzce7X1k l1uPpNd+oMc9HYieJhBodsk3w7h16evq568efEEpiALjjfW5BVd/nzh7jLXGZRH6jcXBz5zLntEarb hswe05EcWStJRv5wqM9/lzy/uJ0YGxo7hm7zNQrmYV9H12hS2IlZOGvg30p90rUp/ILoWqwpIEgXCn znHPq9qmff9cx6xYCdBhFUIh3ZzGPWo5mXBFmC7DacBcKeO0SkCT7O+SO6zf7BbOcahgLzgnH4bTD7 OiYB/P8tqw02ub7MwulSUbiwSX05swg== ARC-Authentication-Results: i=1; outbound4.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:from; bh=uWPU/ke/yRe+PaTbSqTFMOy7e1Jcz6ml0LKeETUDQiw=; b=qBWHTdy51luAAK8xXFc/KI3Y8M374B38mUB/W/idxwsNs6DQl5K2ojMEPbADm34/zCxOlutqn1EmV oWv00vv8H+Hjyj/2BPlTERFQxAcFidOxQ1GByQNPXf258DHrDg54+zxwFpuKHWY+d0VTsTBwgk9xJ/ UjkbGZyKnaTSjcsOPxGKgL+We6v3yn/n3W0vXJuE1aDkvbQ0KhiC7mi1IgCTbVyU/O2CpHuuPePeyp aQX7xANgv/UxyykAjvrdURTqtzb4vI81PpQt8LLguCZWI0GaXvwmX0gexLrNApXDEuSSAvOJFltGdv wT7oD2Wac5hCXamfq0Q64gcK6hNeHVA== X-MHO-RoutePath: aGlwcGll X-MHO-User: c07b120e-36e4-11ea-9eb3-25e2dfa9fa8d X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound4.ore.mailhop.org (Halon) with ESMTPSA id c07b120e-36e4-11ea-9eb3-25e2dfa9fa8d; Tue, 14 Jan 2020 15:44:30 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id 00EFiTN9058752; Tue, 14 Jan 2020 08:44:29 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <24cb346dd9f6de0f094dfa15c592d211e0d8f4a1.camel@freebsd.org> Subject: Re: svn commit: r356725 - head/usr.bin/diff From: Ian Lepore To: Baptiste Daroussin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Tue, 14 Jan 2020 08:44:29 -0700 In-Reply-To: <202001140822.00E8MS1b024516@repo.freebsd.org> References: <202001140822.00E8MS1b024516@repo.freebsd.org> Content-Type: text/plain; charset="ASCII" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 47xvsG0hJpz4JFH X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-1.98 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.986,0]; NEURAL_HAM_LONG(-0.99)[-0.991,0]; ASN(0.00)[asn:16509, ipnet:54.148.0.0/15, country:US] 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 15:44:34 -0000 On Tue, 2020-01-14 at 08:22 +0000, Baptiste Daroussin wrote: > 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. > What's the point of these changes, other than almost certainly leading to worse code generation? In most instruction sets, you can test for a value < 0 without using any instructions, you only need to examine the condition flags after loading the value. To compare equal to -1 typically requires at least 1 extra instruction, and on risc architectures typically at least two extra (load -1 to a register then compare). -- Ian > 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 (r356 > 724) > +++ head/usr.bin/diff/diffreg.c Tue Jan 14 08:22:28 2020 (r356 > 725) > @@ -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--;