remote: avoid -Wunused-but-set-variable in gcc with -DNDEBUG
commit6540b716140784f329de7bac954d2651e9d3e321
authorCarlo Marcelo Arenas Belón <carenas@gmail.com>
Thu, 2 Sep 2021 08:52:53 +0000 (2 04:52 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Sep 2021 20:13:19 +0000 (2 13:13 -0700)
tree1174413f83321e11bf75b2d14b2fcc0ab0cb3f67
parent225bc32a989d7a22fa6addafd4ce7dcd04675dbf
remote: avoid -Wunused-but-set-variable in gcc with -DNDEBUG

In make_remote(), we store the return value of hashmap_put() and check
it using assert(), but don't otherwise use it. If Git is compiled with
NDEBUG, then the assert() becomes a noop, and nobody looks at the
variable at all. This causes some compilers to produce warnings.

Let's switch it instead to a BUG(). This accomplishes the same thing,
but is always compiled in (and we don't have to worry about the cost;
the check is cheap, and this is not a hot code path).

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c