From patchwork Mon Dec 6 16:25:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12658865 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8CE8C433F5 for ; Mon, 6 Dec 2021 16:26:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357751AbhLFQ3l (ORCPT ); Mon, 6 Dec 2021 11:29:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352995AbhLFQ3j (ORCPT ); Mon, 6 Dec 2021 11:29:39 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20CE5C0613F8 for ; Mon, 6 Dec 2021 08:26:10 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id o29so8615122wms.2 for ; Mon, 06 Dec 2021 08:26:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7oAFd+T9bgT/uBHukQ2pj4+iinrlwmq8/pya8UpAF8w=; b=NtMYpSLJyc62XAc1Z5CST9l65OjHIGcWYWRlsSH1JULAWiNwh53yS9kUrZu1CDJtO2 63G70/KpG3pfJ9YtwTpl+kk+7lGNSev3UcR9VPyjFOabAtdJ30f9T9lRZe/JwObdHRfZ pLyJuiSqPq1Gnr8EN0Y1xHnKTvQPLOD6409cmTDCqcoepuLaYt0ZmCpHZmHa/tPZ77zb oy+I05yRjeEKYUORLcBJSkhSF5E3li4pypfpvwsnMDiPuIQ7rsIGa4TvT7x6qREW/R4n qFul1eyvGOTvSCXCEBmz5n3rrds0VKRi7tWkX6CD7cG8BzZa5vaR++v4DQFK3s6NdZV2 JJxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7oAFd+T9bgT/uBHukQ2pj4+iinrlwmq8/pya8UpAF8w=; b=xfPjVf6D4fN3BNJBjm99REfXR1sGyvvssi9CsaEszmnOVC9lKxYRx9HEUPJ9aLvJED al3z2f3Q3pe8UBckOiRNra1U1lSKdpvbIhvPTrmJ+hBb88g5fRSD/JmJnNiDr64/F2/E Opb5kdIbR7mYnvRvoFxkemn6ENJKFt5aIi57gpQnzIYzssXQumZbHjaGbWzKZy+GWc0s +mdoxnZRdRmd5TIVXYwr7WhsQVGeM+1Qjzi+rM7HZhTZynY+KRCAyjitNzHSkbCFlfae ZCYgwTprDaASDA3dVIp3ewc7Pg3rZt6ZGbRLzwaG6v8R14EN0JvoQECMDGCIs0DCaJGA nHGQ== X-Gm-Message-State: AOAM531IOJAnJi2ksmhi/gsx5Ub5jfvRFx/Ya9mrP9xc9ask3hyxeahW 9RD131nnX39wfMb/BmLRcSDyRKuscTFaXQ== X-Google-Smtp-Source: ABdhPJxRpIs00iiXSBQ0yUVNFtWl8wdc9xCB8C0Tu04LjkDp27GM4s4BpYNCbntd0FebPJDvQ+4FXQ== X-Received: by 2002:a7b:cd0b:: with SMTP id f11mr40139198wmj.3.1638807968423; Mon, 06 Dec 2021 08:26:08 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q26sm11740173wrc.39.2021.12.06.08.26.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 08:26:07 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Ren=C3=A9_Scharfe?= , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 1/2] pack-objects: use BUG(...) not die("BUG: ...") Date: Mon, 6 Dec 2021 17:25:20 +0100 Message-Id: X-Mailer: git-send-email 2.34.1.898.g5a552c2e5f0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change this code added in da93d12b004 (pack-objects: be incredibly anal about stdio semantics, 2006-04-02) to use BUG() instead. See 1a07e59c3e2 (Update messages in preparation for i18n, 2018-07-21) for when the "BUG: " prefix was added, and [1] for background on the Solaris behavior that prompted the exhaustive error checking in this fgets() loop. 1. https://lore.kernel.org/git/824.1144007555@lotus.CS.Berkeley.EDU/ Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/pack-objects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 857be7826f3..b36ed828d8d 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -3397,7 +3397,7 @@ static void read_object_list_from_stdin(void) if (feof(stdin)) break; if (!ferror(stdin)) - die("BUG: fgets returned NULL, not EOF, not error!"); + BUG("fgets returned NULL, not EOF, not error!"); if (errno != EINTR) die_errno("fgets"); clearerr(stdin); From patchwork Mon Dec 6 16:25:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12658867 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF85FC433FE for ; Mon, 6 Dec 2021 16:26:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358196AbhLFQ3m (ORCPT ); Mon, 6 Dec 2021 11:29:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356284AbhLFQ3j (ORCPT ); Mon, 6 Dec 2021 11:29:39 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAC06C061746 for ; Mon, 6 Dec 2021 08:26:10 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id az34-20020a05600c602200b0033bf8662572so274471wmb.0 for ; Mon, 06 Dec 2021 08:26:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r8968T3naNuQ5j9UoZ5NsXC+Nitrdb9t+7Ha30Hni7M=; b=E0uBQNGuKesvMVimXddknHjNlUFQ62ewR9V/7njTVNfp5oVvML6Bj/APcmcZ6Jlpy8 1fx7t3C/raAIujwuTPn4XSbc5U6kPHmm2oRucWXC+kWOvbRhcdHsNQOQfVRXe8LYyi/a iVXR8HEV+HBbXs8LJWgYeW898gFoIK3n72hYujr8ET0dBMRJx1inNWg/mwaJ4zqXfdfu VNTmO/dQMM+J4qylnL118dhw6pfMb/5x5whMC+nPzFGzt7c3M5aCF277rqqznbpR2Ld5 y92FWTlgajTt0eoesTMNk+BZSrHzi+JbZpNZmB0XPjRqsog/7p9crl25VYV/oRPIGVzl qN5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r8968T3naNuQ5j9UoZ5NsXC+Nitrdb9t+7Ha30Hni7M=; b=BaRuKnW2mSbyck3tThnoUYkA5J6TASF6c1iEqEV99TNLpwkPNdj8EcR1LnRyvE5CGB TReUjLNutgE2OfPEwYCkgJvGFncvYTjKyOCmN0RZgA6WyjIhtpVqfcKb3XBU5a0AmIAr VrrSbjvIa2HXO/7ayZv6TWsefO8uk98afbqL3B5JEotcwjBH3kbxEp521xaiD1rtWhKx pyk89/OOHeHz/vWk6fOmS8ABgMQIRXLNvWuN+tZuJchkDs0+B9lF+PzRtpjdz1jnopHx 1fIaSI9ItiO31N58ynd74XGbqkgRTiUDc4jOUFR70+3YF6AvpzPy+zm7u9iwxSvTyI3A gGYQ== X-Gm-Message-State: AOAM530yHVdngSfBsmgNqeorZ85Fjqoq0TVAMqfow3p7RMBN7qp4QkVc 9w2dt4zUkIIIqnagRJSpamY7Nfh0XZfWYA== X-Google-Smtp-Source: ABdhPJz5XEztUtogH1557TkUzin+1LgcsSDY0SWzhyYkgp9iGrxebfuUaBuTNhUp5Ct+FJsxoYhbng== X-Received: by 2002:a7b:c38d:: with SMTP id s13mr40120639wmj.12.1638807969258; Mon, 06 Dec 2021 08:26:09 -0800 (PST) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id q26sm11740173wrc.39.2021.12.06.08.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 08:26:08 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?q?Ren=C3=A9_Scharfe?= , Johannes Schindelin , =?utf-8?b?w4Z2YXIgQXJu?= =?utf-8?b?ZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 2/2] strbuf.h: use BUG(...) not die("BUG: ...") Date: Mon, 6 Dec 2021 17:25:21 +0100 Message-Id: X-Mailer: git-send-email 2.34.1.898.g5a552c2e5f0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In 7141efab248 (strbuf: clarify assertion in strbuf_setlen(), 2011-04-27) this 'die("BUG: "' invocation was added with the rationale that strbuf.c had existing users doing the same, but those users were later changed to use BUG() in 033abf97fcb (Replace all die("BUG: ...") calls by BUG() ones, 2018-05-02). Let's do the same here. Signed-off-by: Ævar Arnfjörð Bjarmason --- strbuf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strbuf.h b/strbuf.h index 96512f85b31..76965a17d44 100644 --- a/strbuf.h +++ b/strbuf.h @@ -160,7 +160,7 @@ void strbuf_grow(struct strbuf *sb, size_t amount); static inline void strbuf_setlen(struct strbuf *sb, size_t len) { if (len > (sb->alloc ? sb->alloc - 1 : 0)) - die("BUG: strbuf_setlen() beyond buffer"); + BUG("strbuf_setlen() beyond buffer"); sb->len = len; if (sb->buf != strbuf_slopbuf) sb->buf[len] = '\0'; From patchwork Tue Dec 7 00:24:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 12660615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEE21C433F5 for ; Tue, 7 Dec 2021 00:24:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378260AbhLGA1e (ORCPT ); Mon, 6 Dec 2021 19:27:34 -0500 Received: from pb-smtp2.pobox.com ([64.147.108.71]:64345 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232085AbhLGA1e (ORCPT ); Mon, 6 Dec 2021 19:27:34 -0500 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 3598F10AD89; Mon, 6 Dec 2021 19:24:04 -0500 (EST) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=F8zqaB3XEff8 SfKVMRpELkQQyTCLe6LBqmX0zUi1T1I=; b=vRgdjfFuEuVvGSBnJ+wxNuRbiRLB 7/0eu3xc1LAwIt1Klv9n/BnW0ypTtugcxpMhPTAXqiKun/KMOmtzyLVooyVA/E30 cSHE8eJsp4OdwhPJyAe5jg9LjeoE+BMgpFRXN/Q6VUoG9AIN9VtEaNvMu44c7hQu qZXDm/9kqvIxm8E= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id D2A7410AD88; Mon, 6 Dec 2021 19:24:03 -0500 (EST) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [104.133.2.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id E86FC10AD87; Mon, 6 Dec 2021 19:24:02 -0500 (EST) (envelope-from junio@pobox.com) From: Junio C Hamano To: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason Cc: git@vger.kernel.org, =?utf-8?b?UmVuw6k=?= Scharfe , Johannes Schindelin Subject: [PATCH 3/2] replace die("BUG: ...") with BUG("...") References: Date: Mon, 06 Dec 2021 16:24:01 -0800 In-Reply-To: ( =?utf-8?b?IsOGdmFyCUFybmZqw7Zyw7A=?= Bjarmason"'s message of "Mon, 6 Dec 2021 17:25:19 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Pobox-Relay-ID: FAFF354C-56F3-11EC-AF83-C48D900A682E-77302942!pb-smtp2.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Ævar Arnfjörð Bjarmason writes: > A trivial clean-up to change a couple of die() uses to BUG() where > appropriate. This is split off from an earlier RFC series I sent > in[1], as the range-diff to the relevant patches there shown there are > no changes since then. > > 1. https://lore.kernel.org/git/RFC-patch-07.21-3f897bf6b0e-20211115T220831Z-avarab@gmail.com/ > > Ævar Arnfjörð Bjarmason (2): > pack-objects: use BUG(...) not die("BUG: ...") > strbuf.h: use BUG(...) not die("BUG: ...") > > builtin/pack-objects.c | 2 +- > strbuf.h | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > Range-diff: > 1: 2507ea71700 = 1: 2a17ed9f135 pack-objects: use BUG(...) not die("BUG: ...") > 2: 5dedcee3fb0 = 2: ab89fec50c3 strbuf.h: use BUG(...) not die("BUG: ...") There are a bit more that you didn't include and I am having a hard time guessing why. object.c | 2 +- pathspec.h | 3 +-- tree-diff.c | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git c/object.c w/object.c index 23a24e678a..4be82c1e7b 100644 --- c/object.c +++ w/object.c @@ -199,7 +199,7 @@ struct object *lookup_object_by_type(struct repository *r, case OBJ_BLOB: return (struct object *)lookup_blob(r, oid); default: - die("BUG: unknown object type %d", type); + BUG("unknown object type %d", type); } } diff --git c/pathspec.h w/pathspec.h index 2341dc9901..402ebb8080 100644 --- c/pathspec.h +++ w/pathspec.h @@ -58,8 +58,7 @@ struct pathspec { #define GUARD_PATHSPEC(ps, mask) \ do { \ if ((ps)->magic & ~(mask)) \ - die("BUG:%s:%d: unsupported magic %x", \ - __FILE__, __LINE__, (ps)->magic & ~(mask)); \ + BUG("unsupported magic %x", (ps)->magic & ~(mask)); \ } while (0) /* parse_pathspec flags */ diff --git c/tree-diff.c w/tree-diff.c index 437c98a70e..69031d7cba 100644 --- c/tree-diff.c +++ w/tree-diff.c @@ -603,8 +603,7 @@ static void try_to_follow_renames(const struct object_id *old_oid, * about dry-run mode and returns wildcard info. */ if (opt->pathspec.has_wildcard) - die("BUG:%s:%d: wildcards are not supported", - __FILE__, __LINE__); + BUG("wildcards are not supported"); #endif /* Remove the file creation entry from the diff queue, and remember it */