From nobody Thu Sep 07 14:36:56 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RhMJS741Mz4sg6v; Thu, 7 Sep 2023 14:36:56 +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 4RhMJS6dqDz4g8j; Thu, 7 Sep 2023 14:36:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694097416; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HvxY+98mEQIg+VgkDEJOuVhw34VhMgE5SQKUqnLVeIE=; b=VH8X/6x7rQPrxCNnZy7uMIYFBv8uGO6/U2A+F2PPqOkTzFQCQrU1aw2e0zPM70x+TRpoZG WZl+gBdolR3zpm2+DrC+pUFeEpVTLPyO2oUUtO8uJKowtrtX8HmdbojXncFp00L/QhBgps KGcUT8bsxXDx242o/C6A4kKm3eq2uPYWL1m6dQH9IgE3ja2DOhywpE7LCcQVjiPntaDEaY AKIf5TdpwSp9W8LXtWTAgwEXxLazVR7WR8W8zvOCDStIm2GZHf8uHj+pvUNqZTMYovircg L1fUF6hRIa42A9zu5wVhKKYbJhHxHCRN5rskXUzCwZ0V2P+Zbuy5W4BCBQYkcw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694097416; a=rsa-sha256; cv=none; b=VTzfJZzV9FUz4z6KIRp+dKMBSfBnDkHyLsOXcdVvKM3StBSYfuwO5yuBGOkNnplrfYQJ7j 8f2Z1PdK0tupFUwKCZlH4PMt6/tHSqUEWwZzugvBH55fj8IHVb0qnOybvA3nah9xXzGvQd 4payKZ8FNxfyjBI4C8cg1QJ/9wMOGmXkOgGeyOsUIYIC4B+Fif1PJUpdHAP0jI5/DO8+rU ECuMmrVRXIMSz8TGAebJsjsmtmL4gokKi7UEFWewfJYTzCA4azeGlNGlYSkLpnrTIwIqNb Uu5JIQnHLIeeFEYbrIKkLBcj39bqA9S+EsFyaKcWVOfX89JiM4Hmy1wiPEDKJA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694097416; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HvxY+98mEQIg+VgkDEJOuVhw34VhMgE5SQKUqnLVeIE=; b=nvShenPngksd6K/2Ff7rlp1ln/iMjJSqwKmkQHLyn29uosFBWb/fnxEPkyNgiD7gJ/K4Bv GRnHFPw/Mq+hL7F3xNgbUzgnX9SA7IPdAJ7tSKQRpBS7u4eenzs+M5nehqxM8l7UASEfRj gYWDpj6lktuEFanxD150nVo0nTZ3Mndl6aS6Vr968ZlTfv1SrAFZEuA3F2AZLZnZuVNCx+ sjvaCDiwDp9kiC8SUm8R39NowE2jR++tu/6UnszBsDUbzBfKu2g2fgUDpSjdcW2ptB1XL+ +Cci0agO6WK7pYimXfvfwn2CzDEhn4SAwB/hRMAwHf/HS8k2ZsBc5OUxDqjanw== 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 4RhMJS5drZz13PQ; Thu, 7 Sep 2023 14:36:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 387Eaukq083052; Thu, 7 Sep 2023 14:36:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 387Eaugx083049; Thu, 7 Sep 2023 14:36:56 GMT (envelope-from git) Date: Thu, 7 Sep 2023 14:36:56 GMT Message-Id: <202309071436.387Eaugx083049@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: ee12faa062c0 - main - bspatch: use C23 overflow checking math now that it is available List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ee12faa062c04a49bf6fe4e6867bad8606e2413f Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=ee12faa062c04a49bf6fe4e6867bad8606e2413f commit ee12faa062c04a49bf6fe4e6867bad8606e2413f Author: Ed Maste AuthorDate: 2023-09-05 16:35:31 +0000 Commit: Ed Maste CommitDate: 2023-09-07 14:36:50 +0000 bspatch: use C23 overflow checking math now that it is available Reviewed by: des Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41771 --- usr.bin/bsdiff/bspatch/bspatch.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/usr.bin/bsdiff/bspatch/bspatch.c b/usr.bin/bsdiff/bspatch/bspatch.c index a596ab1837dd..d7fabddabbfe 100644 --- a/usr.bin/bsdiff/bspatch/bspatch.c +++ b/usr.bin/bsdiff/bspatch/bspatch.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -64,15 +65,8 @@ add_off_t(off_t a, off_t b) { off_t result; -#if __GNUC__ >= 5 || \ - (defined(__has_builtin) && __has_builtin(__builtin_add_overflow)) - if (__builtin_add_overflow(a, b, &result)) + if (ckd_add(&result, a, b)) errx(1, "Corrupt patch"); -#else - if ((b > 0 && a > OFF_MAX - b) || (b < 0 && a < OFF_MIN - b)) - errx(1, "Corrupt patch"); - result = a + b; -#endif return result; }