{"thread":{"id":"57038","subject":"[PATCH 0/2] replace die(\"BUG: ...\") with BUG(\"...\")","startedAt":"2021-12-06T16:26:13Z","lastAt":"2021-12-07T11:06:37Z","messageCount":11,"participants":["Ævar Arnfjörð Bjarmason","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"443166","messageId":"cover-0.2-00000000000-20211206T162442Z-avarab@gmail.com","threadId":"57038","inReplyTo":null,"subject":"[PATCH 0/2] replace die(\"BUG: ...\") with BUG(\"...\")","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-12-06T16:25:19Z","receivedAt":"2021-12-06T16:26:13Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"A trivial clean-up to change a couple of die() uses to BUG() where\nappropriate. This is split off from an earlier RFC series I sent\nin[1], as the range-diff to the relevant patches there shown there are\nno changes since then.\n\n1. https://lore.kernel.org/git/RFC-patch-07.21-3f897bf6b0e-20211115T220831Z-avarab@gmail.com/\n\nÆvar Arnfjörð Bjarmason (2):\n  pack-objects: use BUG(...) not die(\"BUG: ...\")\n  strbuf.h: use BUG(...) not die(\"BUG: ...\")\n\n builtin/pack-objects.c | 2 +-\n strbuf.h               | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\nRange-diff:\n1:  2507ea71700 = 1:  2a17ed9f135 pack-objects: use BUG(...) not die(\"BUG: ...\")\n2:  5dedcee3fb0 = 2:  ab89fec50c3 strbuf.h: use BUG(...) not die(\"BUG: ...\")\n-- \n2.34.1.898.g5a552c2e5f0\n\n"},{"id":"443167","messageId":"patch-1.2-2a17ed9f135-20211206T162442Z-avarab@gmail.com","threadId":"57038","inReplyTo":"cover-0.2-00000000000-20211206T162442Z-avarab@gmail.com","subject":"[PATCH 1/2] pack-objects: use BUG(...) not die(\"BUG: ...\")","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-12-06T16:25:20Z","receivedAt":"2021-12-06T16:26:13Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change this code added in da93d12b004 (pack-objects: be incredibly\nanal about stdio semantics, 2006-04-02) to use BUG() instead.\n\nSee 1a07e59c3e2 (Update messages in preparation for i18n, 2018-07-21)\nfor when the \"BUG: \" prefix was added, and [1] for background on the\nSolaris behavior that prompted the exhaustive error checking in this\nfgets() loop.\n\n1. https://lore.kernel.org/git/824.1144007555@lotus.CS.Berkeley.EDU/\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/pack-objects.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 857be7826f3..b36ed828d8d 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -3397,7 +3397,7 @@ static void read_object_list_from_stdin(void)\n \t\t\tif (feof(stdin))\n \t\t\t\tbreak;\n \t\t\tif (!ferror(stdin))\n-\t\t\t\tdie(\"BUG: fgets returned NULL, not EOF, not error!\");\n+\t\t\t\tBUG(\"fgets returned NULL, not EOF, not error!\");\n \t\t\tif (errno != EINTR)\n \t\t\t\tdie_errno(\"fgets\");\n \t\t\tclearerr(stdin);\n-- \n2.34.1.898.g5a552c2e5f0\n\n"},{"id":"443168","messageId":"patch-2.2-ab89fec50c3-20211206T162442Z-avarab@gmail.com","threadId":"57038","inReplyTo":"cover-0.2-00000000000-20211206T162442Z-avarab@gmail.com","subject":"[PATCH 2/2] strbuf.h: use BUG(...) not die(\"BUG: ...\")","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-12-06T16:25:21Z","receivedAt":"2021-12-06T16:26:14Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In 7141efab248 (strbuf: clarify assertion in strbuf_setlen(),\n2011-04-27) this 'die(\"BUG: \"' invocation was added with the rationale\nthat strbuf.c had existing users doing the same, but those users were\nlater changed to use BUG() in 033abf97fcb (Replace all die(\"BUG: ...\")\ncalls by BUG() ones, 2018-05-02). Let's do the same here.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n strbuf.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/strbuf.h b/strbuf.h\nindex 96512f85b31..76965a17d44 100644\n--- a/strbuf.h\n+++ b/strbuf.h\n@@ -160,7 +160,7 @@ void strbuf_grow(struct strbuf *sb, size_t amount);\n static inline void strbuf_setlen(struct strbuf *sb, size_t len)\n {\n \tif (len > (sb->alloc ? sb->alloc - 1 : 0))\n-\t\tdie(\"BUG: strbuf_setlen() beyond buffer\");\n+\t\tBUG(\"strbuf_setlen() beyond buffer\");\n \tsb->len = len;\n \tif (sb->buf != strbuf_slopbuf)\n \t\tsb->buf[len] = '\\0';\n-- \n2.34.1.898.g5a552c2e5f0\n\n"},{"id":"443187","messageId":"xmqqv901fu8m.fsf@gitster.g","threadId":"57038","inReplyTo":"cover-0.2-00000000000-20211206T162442Z-avarab@gmail.com","subject":"Re: [PATCH 0/2] replace die(\"BUG: ...\") with BUG(\"...\")","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-12-06T18:44:57Z","receivedAt":"2021-12-06T18:45:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> A trivial clean-up to change a couple of die() uses to BUG() where\n> appropriate.\n\nMakes sense.  I wonder contrib/coccinelle/ can help us maintain\nthem, though.\n\nWill queue.\n\nThanks.\n\n\n"},{"id":"443216","messageId":"xmqqsfv5b6u6.fsf@gitster.g","threadId":"57038","inReplyTo":"cover-0.2-00000000000-20211206T162442Z-avarab@gmail.com","subject":"[PATCH 3/2] replace die(\"BUG: ...\") with BUG(\"...\")","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-12-07T00:24:01Z","receivedAt":"2021-12-07T00:24:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> A trivial clean-up to change a couple of die() uses to BUG() where\n> appropriate. This is split off from an earlier RFC series I sent\n> in[1], as the range-diff to the relevant patches there shown there are\n> no changes since then.\n>\n> 1. https://lore.kernel.org/git/RFC-patch-07.21-3f897bf6b0e-20211115T220831Z-avarab@gmail.com/\n>\n> Ævar Arnfjörð Bjarmason (2):\n>   pack-objects: use BUG(...) not die(\"BUG: ...\")\n>   strbuf.h: use BUG(...) not die(\"BUG: ...\")\n>\n>  builtin/pack-objects.c | 2 +-\n>  strbuf.h               | 2 +-\n>  2 files changed, 2 insertions(+), 2 deletions(-)\n>\n> Range-diff:\n> 1:  2507ea71700 = 1:  2a17ed9f135 pack-objects: use BUG(...) not die(\"BUG: ...\")\n> 2:  5dedcee3fb0 = 2:  ab89fec50c3 strbuf.h: use BUG(...) not die(\"BUG: ...\")\n\nThere are a bit more that you didn't include and I am having a hard\ntime guessing why.\n\n object.c    | 2 +-\n pathspec.h  | 3 +--\n tree-diff.c | 3 +--\n 3 files changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git c/object.c w/object.c\nindex 23a24e678a..4be82c1e7b 100644\n--- c/object.c\n+++ w/object.c\n@@ -199,7 +199,7 @@ struct object *lookup_object_by_type(struct repository *r,\n \tcase OBJ_BLOB:\n \t\treturn (struct object *)lookup_blob(r, oid);\n \tdefault:\n-\t\tdie(\"BUG: unknown object type %d\", type);\n+\t\tBUG(\"unknown object type %d\", type);\n \t}\n }\n \ndiff --git c/pathspec.h w/pathspec.h\nindex 2341dc9901..402ebb8080 100644\n--- c/pathspec.h\n+++ w/pathspec.h\n@@ -58,8 +58,7 @@ struct pathspec {\n #define GUARD_PATHSPEC(ps, mask) \\\n \tdo { \\\n \t\tif ((ps)->magic & ~(mask))\t       \\\n-\t\t\tdie(\"BUG:%s:%d: unsupported magic %x\",\t\\\n-\t\t\t    __FILE__, __LINE__, (ps)->magic & ~(mask)); \\\n+\t\t\tBUG(\"unsupported magic %x\", (ps)->magic & ~(mask)); \\\n \t} while (0)\n \n /* parse_pathspec flags */\ndiff --git c/tree-diff.c w/tree-diff.c\nindex 437c98a70e..69031d7cba 100644\n--- c/tree-diff.c\n+++ w/tree-diff.c\n@@ -603,8 +603,7 @@ static void try_to_follow_renames(const struct object_id *old_oid,\n \t * about dry-run mode and returns wildcard info.\n \t */\n \tif (opt->pathspec.has_wildcard)\n-\t\tdie(\"BUG:%s:%d: wildcards are not supported\",\n-\t\t    __FILE__, __LINE__);\n+\t\tBUG(\"wildcards are not supported\");\n #endif\n \n \t/* Remove the file creation entry from the diff queue, and remember it */\n"},{"id":"443259","messageId":"211207.86a6hcptjs.gmgdl@evledraar.gmail.com","threadId":"57038","inReplyTo":"xmqqv901fu8m.fsf@gitster.g","subject":"Re: [PATCH 0/2] replace die(\"BUG: ...\") with BUG(\"...\")","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-12-07T11:00:42Z","receivedAt":"2021-12-07T11:02:06Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Dec 06 2021, Junio C Hamano wrote:\n\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> A trivial clean-up to change a couple of die() uses to BUG() where\n>> appropriate.\n>\n> Makes sense.  I wonder contrib/coccinelle/ can help us maintain\n> them, though.\n\nI tried to come up with a rule for this after browsing around in linux's\nsources & coccicheck's own test cases, but didn't find any example I\ncould adapt. It's rather thin on string munging like that, and I don't\nknow spatch well enough.\n"},{"id":"443260","messageId":"cover-v2-0.4-00000000000-20211207T110440Z-avarab@gmail.com","threadId":"57038","inReplyTo":"cover-0.2-00000000000-20211206T162442Z-avarab@gmail.com","subject":"[PATCH v2 0/4] replace die(\"BUG: ...\") with BUG(\"...\")","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-12-07T11:05:50Z","receivedAt":"2021-12-07T11:06:30Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"A re-roll of this trivial clean-up series, now with 2x more patches\nfor missed cases pointed-out by Junio at\nhttps://lore.kernel.org/git/xmqqsfv5b6u6.fsf@gitster.g/\n\nÆvar Arnfjörð Bjarmason (4):\n  pack-objects: use BUG(...) not die(\"BUG: ...\")\n  strbuf.h: use BUG(...) not die(\"BUG: ...\")\n  pathspec: use BUG(...) not die(\"BUG:%s:%d....\", <file>, <line>)\n  object.h: use BUG(...) no die(\"BUG: ...\") in lookup_object_by_type()\n\n builtin/pack-objects.c | 2 +-\n object.c               | 2 +-\n pathspec.h             | 3 +--\n strbuf.h               | 2 +-\n tree-diff.c            | 3 +--\n 5 files changed, 5 insertions(+), 7 deletions(-)\n\nRange-diff against v1:\n1:  2a17ed9f135 = 1:  4f39177a763 pack-objects: use BUG(...) not die(\"BUG: ...\")\n2:  ab89fec50c3 = 2:  6740c5d0da8 strbuf.h: use BUG(...) not die(\"BUG: ...\")\n-:  ----------- > 3:  81e354fa3be pathspec: use BUG(...) not die(\"BUG:%s:%d....\", <file>, <line>)\n-:  ----------- > 4:  aaf952a9ede object.h: use BUG(...) no die(\"BUG: ...\") in lookup_object_by_type()\n-- \n2.34.1.898.g5a552c2e5f0\n\n"},{"id":"443261","messageId":"patch-v2-1.4-4f39177a763-20211207T110440Z-avarab@gmail.com","threadId":"57038","inReplyTo":"cover-v2-0.4-00000000000-20211207T110440Z-avarab@gmail.com","subject":"[PATCH v2 1/4] pack-objects: use BUG(...) not die(\"BUG: ...\")","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-12-07T11:05:51Z","receivedAt":"2021-12-07T11:06:31Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change this code added in da93d12b004 (pack-objects: be incredibly\nanal about stdio semantics, 2006-04-02) to use BUG() instead.\n\nSee 1a07e59c3e2 (Update messages in preparation for i18n, 2018-07-21)\nfor when the \"BUG: \" prefix was added, and [1] for background on the\nSolaris behavior that prompted the exhaustive error checking in this\nfgets() loop.\n\n1. https://lore.kernel.org/git/824.1144007555@lotus.CS.Berkeley.EDU/\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/pack-objects.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 857be7826f3..b36ed828d8d 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -3397,7 +3397,7 @@ static void read_object_list_from_stdin(void)\n \t\t\tif (feof(stdin))\n \t\t\t\tbreak;\n \t\t\tif (!ferror(stdin))\n-\t\t\t\tdie(\"BUG: fgets returned NULL, not EOF, not error!\");\n+\t\t\t\tBUG(\"fgets returned NULL, not EOF, not error!\");\n \t\t\tif (errno != EINTR)\n \t\t\t\tdie_errno(\"fgets\");\n \t\t\tclearerr(stdin);\n-- \n2.34.1.898.g5a552c2e5f0\n\n"},{"id":"443262","messageId":"patch-v2-2.4-6740c5d0da8-20211207T110440Z-avarab@gmail.com","threadId":"57038","inReplyTo":"cover-v2-0.4-00000000000-20211207T110440Z-avarab@gmail.com","subject":"[PATCH v2 2/4] strbuf.h: use BUG(...) not die(\"BUG: ...\")","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-12-07T11:05:52Z","receivedAt":"2021-12-07T11:06:32Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In 7141efab248 (strbuf: clarify assertion in strbuf_setlen(),\n2011-04-27) this 'die(\"BUG: \"' invocation was added with the rationale\nthat strbuf.c had existing users doing the same, but those users were\nlater changed to use BUG() in 033abf97fcb (Replace all die(\"BUG: ...\")\ncalls by BUG() ones, 2018-05-02). Let's do the same here.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n strbuf.h | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/strbuf.h b/strbuf.h\nindex 96512f85b31..76965a17d44 100644\n--- a/strbuf.h\n+++ b/strbuf.h\n@@ -160,7 +160,7 @@ void strbuf_grow(struct strbuf *sb, size_t amount);\n static inline void strbuf_setlen(struct strbuf *sb, size_t len)\n {\n \tif (len > (sb->alloc ? sb->alloc - 1 : 0))\n-\t\tdie(\"BUG: strbuf_setlen() beyond buffer\");\n+\t\tBUG(\"strbuf_setlen() beyond buffer\");\n \tsb->len = len;\n \tif (sb->buf != strbuf_slopbuf)\n \t\tsb->buf[len] = '\\0';\n-- \n2.34.1.898.g5a552c2e5f0\n\n"},{"id":"443263","messageId":"patch-v2-3.4-81e354fa3be-20211207T110440Z-avarab@gmail.com","threadId":"57038","inReplyTo":"cover-v2-0.4-00000000000-20211207T110440Z-avarab@gmail.com","subject":"[PATCH v2 3/4] pathspec: use BUG(...) not die(\"BUG:%s:%d....\", <file>, <line>)","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-12-07T11:05:53Z","receivedAt":"2021-12-07T11:06:34Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change code that was added in 8f4f8f4579f (guard against new pathspec\nmagic in pathspec matching code, 2013-07-14) to use the BUG() macro\ninstead of emitting a \"fatal\" message with the \"__FILE__\"-name and\n\"__LINE__\"-numbers.\n\nThe original code predated the existence of the BUG() function, which\nwas added in d8193743e08 (usage.c: add BUG() function, 2017-05-12).\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n pathspec.h  | 3 +--\n tree-diff.c | 3 +--\n 2 files changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/pathspec.h b/pathspec.h\nindex 2341dc99010..402ebb80808 100644\n--- a/pathspec.h\n+++ b/pathspec.h\n@@ -58,8 +58,7 @@ struct pathspec {\n #define GUARD_PATHSPEC(ps, mask) \\\n \tdo { \\\n \t\tif ((ps)->magic & ~(mask))\t       \\\n-\t\t\tdie(\"BUG:%s:%d: unsupported magic %x\",\t\\\n-\t\t\t    __FILE__, __LINE__, (ps)->magic & ~(mask)); \\\n+\t\t\tBUG(\"unsupported magic %x\", (ps)->magic & ~(mask)); \\\n \t} while (0)\n \n /* parse_pathspec flags */\ndiff --git a/tree-diff.c b/tree-diff.c\nindex 437c98a70e4..69031d7cbae 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -603,8 +603,7 @@ static void try_to_follow_renames(const struct object_id *old_oid,\n \t * about dry-run mode and returns wildcard info.\n \t */\n \tif (opt->pathspec.has_wildcard)\n-\t\tdie(\"BUG:%s:%d: wildcards are not supported\",\n-\t\t    __FILE__, __LINE__);\n+\t\tBUG(\"wildcards are not supported\");\n #endif\n \n \t/* Remove the file creation entry from the diff queue, and remember it */\n-- \n2.34.1.898.g5a552c2e5f0\n\n"},{"id":"443264","messageId":"patch-v2-4.4-aaf952a9ede-20211207T110440Z-avarab@gmail.com","threadId":"57038","inReplyTo":"cover-v2-0.4-00000000000-20211207T110440Z-avarab@gmail.com","subject":"[PATCH v2 4/4] object.h: use BUG(...) no die(\"BUG: ...\") in lookup_object_by_type()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-12-07T11:05:54Z","receivedAt":"2021-12-07T11:06:37Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Adjust code added in 7463064b280 (object.h: add\nlookup_object_by_type() function, 2021-06-22) to use the BUG()\nfunction.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n object.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/object.c b/object.c\nindex 23a24e678a8..4be82c1e7bc 100644\n--- a/object.c\n+++ b/object.c\n@@ -199,7 +199,7 @@ struct object *lookup_object_by_type(struct repository *r,\n \tcase OBJ_BLOB:\n \t\treturn (struct object *)lookup_blob(r, oid);\n \tdefault:\n-\t\tdie(\"BUG: unknown object type %d\", type);\n+\t\tBUG(\"unknown object type %d\", type);\n \t}\n }\n \n-- \n2.34.1.898.g5a552c2e5f0\n\n"}]}