Re: [PATCH v2 2/3] ci: add build checking for side-effects in assert() calls
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 17, 2025, 22:37 UTC
- Message-ID
- <xmqqfrjb707x.fsf@gitster.g>
- In-Reply-To
- <58cb8f6a1609b10d761e86bdad541d1c018cb582.1742107322.git.gitgitgadget@gmail.com>
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 6 quoted lines
> ... All but 9 of them can be determined by gcc to be free of side > effects with a clever redefine of assert() provided by Bruno De Fraine > (from > https://stackoverflow.com/questions/10593492/catching-assert-with-side-effects), > who upon request has graciously placed his two-liner into the public > domain without warranty of any kind.
Nice.
Show 17 quoted lines
> diff --git a/ci/check-unsafe-assertions.sh b/ci/check-unsafe-assertions.sh > new file mode 100755 > index 00000000000..d66091efd22 > --- /dev/null > +++ b/ci/check-unsafe-assertions.sh > @@ -0,0 +1,18 @@ > +#!/bin/sh > + > +make CHECK_ASSERTION_SIDE_EFFECTS=1 >compiler_output 2>compiler_error > +if test $? != 0 > +then > + echo "ERROR: The compiler could not verify the following assert()" >&2 > + echo " calls are free of side-effects. Please replace with" >&2 > + echo " BUG_IF_NOT() calls." >&2 > + grep undefined.reference.to..not_supposed_to_survive compiler_error \ > + | sed -e s/:[^:]*$// | sort | uniq | tr ':' ' ' \ > + | while read f l
Let's lose the unsightly backslash by ending each line with "|" instead.
Also let's stick to HT indentation, not whitespaces.
Thanks.