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

Re: [PATCH v2 0/6] usage API: add and use a bug() + BUG_if_bug()

From
Josh Steadmon <steadmon@google.com>
Date
May 31, 2022, 17:39 UTC
Message-ID
<YpZS7sYGfWeDJz6o@google.com>
In-Reply-To
<cover-v2-0.6-00000000000-20220531T164806Z-avarab@gmail.com>
On 2022.05.31 18:58, Ævar Arnfjörð Bjarmason wrote:
Show 57 quoted lines
> This series adds a bug() (lower-case) function to go along with
> BUG(). As seen in 3-5/6 this makes it much easier to handle the cases
> such as parse-options.c where we'd like to call BUG(), but would like
> to first exhaustively accumulate the N issues we spot before doing so,
> and not merely BUG() out on the first one.
> 
> Changes since v1
> (https://lore.kernel.org/git/cover-0.5-00000000000-20220521T170939Z-avarab@gmail.com/):
> 
>  * Move the exit() wrapper to common-main.c, I tried to add a
>    "common-exit.c" or just rename "common-main.c" to "common.c", but
>    due to how the CMake build system declares it those changes would
>    result in a lot of churn, so for now just adding it to
>    common-main.c makes more sense.
> 
>  * Typo/grammar fixes in commit messages, as pointed out in review.
> 
>  * The BUG_if_bug() function is now optional, and the docs have been
>    updated to reflect that.
> 
>  * The BUG_if_bug() function now takes a va_args like BUG() to
>    indicate what the problem was.
> 
>  * Updated 3/6 to note that the exit(128) code changes with a
>    migration to BUG().
> 
>  * Fix logic error in 4/6: We now "break" after calling bug(), to
>    behave as the previous code did.
> 
>  * Fix logic error in 5/6, which now makes use of the new argument(s)
>    to BUG_if_bug().
> 
>  * There was some suggestion of ejecting 6/6, but I've instead
>    replaced it with the implementation Glen suggested in
>    http://lore.kernel.org/git/kl6lk0a6mzp0.fsf@chooglen-macbookpro.roam.corp.google.com
> 
> Ævar Arnfjörð Bjarmason (6):
>   common-main.o: move non-trace2 exit() behavior out of trace2.c
>   usage.c: add a non-fatal bug() function to go with BUG()
>   parse-options.c: use new bug() API for optbug()
>   parse-options.c: use optbug() instead of BUG() "opts" check
>   receive-pack: use bug() and BUG_if_bug()
>   cache-tree.c: use bug() and BUG_if_bug()
> 
>  .../technical/api-error-handling.txt          | 19 +++++-
>  Documentation/technical/api-trace2.txt        |  4 +-
>  builtin/receive-pack.c                        | 16 ++---
>  cache-tree.c                                  |  8 +--
>  common-main.c                                 | 30 ++++++++-
>  git-compat-util.h                             | 24 ++++++-
>  parse-options.c                               | 67 ++++++++++---------
>  t/helper/test-trace2.c                        | 22 +++++-
>  t/t0210-trace2-normal.sh                      | 52 ++++++++++++++
>  trace2.c                                      |  8 +--
>  trace2.h                                      |  8 +--
>  usage.c                                       | 30 +++++++--
>  12 files changed, 217 insertions(+), 71 deletions(-)

Thanks for the updates! I have a minor question about 4/6, but regardless of if/how that's addressed, I think this version looks good.

Reviewed-by: Josh Steadmon <steadmon@google.com>
Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 36 of 49 in “usage API: add and use a bug() + BUG_if_bug()”
  1. 0/5 usage API: add and use a bug() + BUG_if_bug()Ævar Arnfjörð Bjarmason, May 21, 2022
  2. 1/5 usage.c: add a non-fatal bug() function to go with BUG()Ævar Arnfjörð Bjarmason, May 21, 2022
  3. Junio C HamanoMay 25, 2022
  4. Junio C HamanoMay 26, 2022
  5. Ævar Arnfjörð BjarmasonMay 26, 2022
  6. Junio C HamanoMay 26, 2022
  7. Ævar Arnfjörð BjarmasonMay 26, 2022
  8. Junio C HamanoMay 26, 2022
  9. Ævar Arnfjörð BjarmasonMay 31, 2022
  10. Josh SteadmonMay 27, 2022
  11. Junio C HamanoMay 27, 2022
  12. 2/5 parse-options.c: use new bug() API for optbug()Ævar Arnfjörð Bjarmason, May 21, 2022
  13. Josh SteadmonMay 27, 2022
  14. 3/5 parse-options.c: use optbug() instead of BUG() "opts" checkÆvar Arnfjörð Bjarmason, May 21, 2022
  15. Junio C HamanoMay 25, 2022
  16. 4/5 receive-pack: use bug() and BUG_if_bug()Ævar Arnfjörð Bjarmason, May 21, 2022
  17. Junio C HamanoMay 25, 2022
  18. Josh SteadmonMay 27, 2022
  19. Andrei RybakMay 27, 2022
  20. 5/5 cache-tree.c: use bug() and BUG_if_bug()Ævar Arnfjörð Bjarmason, May 21, 2022
  21. Glen ChooMay 27, 2022
  22. Josh SteadmonMay 27, 2022
  23. 0/6 usage API: add and use a bug() + BUG_if_bug()Ævar Arnfjörð Bjarmason, May 31, 2022
  24. 1/6 common-main.o: move non-trace2 exit() behavior out of trace2.cÆvar Arnfjörð Bjarmason, May 31, 2022
  25. Junio C HamanoJun 1, 2022
  26. 2/6 usage.c: add a non-fatal bug() function to go with BUG()Ævar Arnfjörð Bjarmason, May 31, 2022
  27. Glen ChooMay 31, 2022
  28. Junio C HamanoJun 1, 2022
  29. 3/6 parse-options.c: use new bug() API for optbug()Ævar Arnfjörð Bjarmason, May 31, 2022
  30. 4/6 parse-options.c: use optbug() instead of BUG() "opts" checkÆvar Arnfjörð Bjarmason, May 31, 2022
  31. Josh SteadmonMay 31, 2022
  32. Junio C HamanoJun 1, 2022
  33. 5/6 receive-pack: use bug() and BUG_if_bug()Ævar Arnfjörð Bjarmason, May 31, 2022
  34. 6/6 cache-tree.c: use bug() and BUG_if_bug()Ævar Arnfjörð Bjarmason, May 31, 2022
  35. Junio C HamanoJun 1, 2022
  36. Josh SteadmonMay 31, 2022
  37. 0/6 usage API: add and use a bug() + BUG_if_bug()Ævar Arnfjörð Bjarmason, Jun 2, 2022
  38. 1/6 common-main.o: move non-trace2 exit() behavior out of trace2.cÆvar Arnfjörð Bjarmason, Jun 2, 2022
  39. Junio C HamanoJun 3, 2022
  40. Josh SteadmonJun 7, 2022
  41. Ævar Arnfjörð BjarmasonJun 7, 2022
  42. Josh SteadmonJun 7, 2022
  43. 3/6 parse-options.c: use new bug() API for optbug()Ævar Arnfjörð Bjarmason, Jun 2, 2022
  44. 2/6 usage.c: add a non-fatal bug() function to go with BUG()Ævar Arnfjörð Bjarmason, Jun 2, 2022
  45. 5/6 receive-pack: use bug() and BUG_if_bug()Ævar Arnfjörð Bjarmason, Jun 2, 2022
  46. 4/6 parse-options.c: use optbug() instead of BUG() "opts" checkÆvar Arnfjörð Bjarmason, Jun 2, 2022
  47. 6/6 cache-tree.c: use bug() and BUG_if_bug()Ævar Arnfjörð Bjarmason, Jun 2, 2022
  48. Junio C HamanoJun 2, 2022
  49. Glen ChooJun 2, 2022

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.