From owner-dev-commits-src-all@freebsd.org Wed Sep 15 23:59:52 2021 Return-Path: Delivered-To: dev-commits-src-all@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 7C024670B9D; Wed, 15 Sep 2021 23:59:52 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H8xzD2hmgz3mwN; Wed, 15 Sep 2021 23:59:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 323C8175AB; Wed, 15 Sep 2021 23:59:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18FNxqc1011145; Wed, 15 Sep 2021 23:59:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18FNxqpg011144; Wed, 15 Sep 2021 23:59:52 GMT (envelope-from git) Date: Wed, 15 Sep 2021 23:59:52 GMT Message-Id: <202109152359.18FNxqpg011144@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Pawel Stefaniak Subject: git: bcf2e78dc483 - main - diff: replace isqrt() with sqrt() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pstef X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bcf2e78dc48378456798191f1c15cb76d6221a65 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Sep 2021 23:59:52 -0000 The branch main has been updated by pstef: URL: https://cgit.FreeBSD.org/src/commit/?id=bcf2e78dc48378456798191f1c15cb76d6221a65 commit bcf2e78dc48378456798191f1c15cb76d6221a65 Author: Piotr Pawel Stefaniak AuthorDate: 2021-09-05 00:42:56 +0000 Commit: Piotr Pawel Stefaniak CommitDate: 2021-09-15 23:46:43 +0000 diff: replace isqrt() with sqrt() Remove cruft and use a system-provided and maintained function instead. --- usr.bin/diff/diffreg.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index 45821ad96e8c..c743c862f2d6 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -194,7 +195,6 @@ static int fetch(long *, int, int, FILE *, int, int, int); static int newcand(int, int, int); static int search(int *, int, int); static int skipline(FILE *); -static int isqrt(int); static int stone(int *, int, int *, int *, int); static enum readhash readhash(FILE *, int, unsigned *); static int files_differ(FILE *, FILE *, int); @@ -569,25 +569,6 @@ equiv(struct line *a, int n, struct line *b, int m, int *c) c[j] = -1; } -/* Code taken from ping.c */ -static int -isqrt(int n) -{ - int y, x = 1; - - if (n == 0) - return (0); - - do { /* newton was a stinker */ - y = x; - x = n / x; - x += y; - x /= 2; - } while ((x - y) > 1 || (x - y) < -1); - - return (x); -} - static int stone(int *a, int n, int *b, int *c, int flags) { @@ -598,7 +579,7 @@ stone(int *a, int n, int *b, int *c, int flags) if (flags & D_MINIMAL) bound = UINT_MAX; else { - sq = isqrt(n); + sq = sqrt(n); bound = MAX(256, sq); }