Skip to content

Introduce BUG_ON(cond, msg) MACRO

Stefan Beller git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 14 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3Documentation/CodingGuidelines: explain why assert is badDocumentation/CodingGuidelines+3 -03 replies
2/3git-compat: introduce BUG_ON(condition, fmt, ...) macrogit-compat-util.h usage.c+15 -12 replies
3/3contrib/coccinelle: convert all conditional bugs to bug_onbuiltin/merge.c contrib/coccinelle/bug_on.cocci environment.c +6 more+56 -580 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] Introduce BUG_ON(cond, msg) MACRO

On reviewing [1] I wondered why there are so many asserts and wondered if these asserts could have been prevented by a better functionality around bug reporting in our code.

Introduce a BUG_ON macro, which is superior to assert() by
* being always there, even when compiled with NDEBUG and
* providind an additional human readable error message, like BUG()

Opinions?

Thanks,
Stefan

[1] https://public-inbox.org/git/[email protected]/

Stefan Beller (3):
Documentation/CodingGuidelines: explain why assert is bad
git-compat: introduce BUG_ON(condition, fmt, ...) macro contrib/coccinelle: convert all conditional bugs to bug_on

 Documentation/CodingGuidelines  |  3 +++
 builtin/merge.c                 |  3 +--
 contrib/coccinelle/bug_on.cocci |  8 ++++++++
 environment.c                   | 22 ++++++++++------------
 git-compat-util.h               |  4 ++++
 notes.c                         |  9 +++++----
 refs.c                          |  7 +++----
 refs/files-backend.c            | 14 ++++++--------
 refs/packed-backend.c           | 13 +++++--------
 sha1_file.c                     |  4 ++--
 tempfile.c                      | 34 ++++++++++++++++------------------
 usage.c                         | 12 +++++++++++-
 12 files changed, 74 insertions(+), 59 deletions(-)
 create mode 100644 contrib/coccinelle/bug_on.cocci
Signature · 1 line
2.15.0.448.gf294e3d99a-goog