git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] list-objects-filter-options: fix function name in BUG

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Nov 17, 2020, 18:02 UTC
Message-ID
<CAN0heSoGnAKjTz2tiHpe2==Y-w7M03eiEpW2hU67FRbv=G+H8w@mail.gmail.com>
In-Reply-To
<20201117021318.GA30463@coredump.intra.peff.net>
On Tue, 17 Nov 2020 at 03:13, Jeff King <peff@peff.net> wrote:
Show 20 quoted lines
>
> On Sat, Nov 14, 2020 at 09:43:26AM +0100, Martin Ågren wrote:
>
> > Fix the function name we give in the BUG message. It's "config", not
> > "choice".
>
> Yep, obviously an improvement.
>
> But as a general rule, I don't think we even need to include function
> names here. The message would look like:
>
>   BUG: list-objects-filter-options.c:20: list_object_filter_choice_name: invalid argument '3'
>
> which already tells us where the code is[1]. Perhaps:
>
>   BUG("invalid filter choice enum: %d", c);
>
> would be shorter but equally informative (I don't overly care here,
> since the idea is that nobody sees it, but just making a point about the
> future).

Having the function name or something else making the string unique across the codebase could be useful if the compiler doesn't support variadic macros -- we'll fall back to using a function instead of a macro, and can't use __FILE__ and __LINE__. (You obviously know all of this, having written d8193743e0 ("usage.c: add BUG() function", 2017-05-12).)

Now, this here BUG shouldn't be a "freak" bug which happens to trigger under very special circumstances, and where it's not even clear which of 25 equal BUG messages it is that we're seeing. If you add a new enum value and forget to add a case in this function, you should hit this BUG quite quickly and very reliably.

All of that said, "don't overly care" also matches my feeling pretty well.

Martin
Previous: Jeff KingNext: Jeff King
Message 3 of 8 in “list-objects-filter-options: fix function name in BUG”
  1. list-objects-filter-options: fix function name in BUGMartin Ågren, Nov 14, 2020
  2. Jeff KingNov 17, 2020
  3. Martin ÅgrenNov 17, 2020
  4. Jeff KingNov 17, 2020
  5. Eric SunshineNov 17, 2020
  6. Jeff KingNov 18, 2020
  7. Jonathan NiederNov 18, 2020
  8. Martin ÅgrenNov 18, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.