Re: [PATCH v4 4/5] Add reftable library
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 6, 2020, 23:07 UTC
- Message-ID
- <xmqqftfne2nf.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <02d2ca8b878a67a3334b222725645dd035b4289c.1581029756.git.gitgitgadget@gmail.com>
"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 15 quoted lines
> +static struct block_stats *writer_block_stats(struct writer *w, byte typ)
> +{
> + switch (typ) {
> + case 'r':
> + return &w->stats.ref_stats;
> + case 'o':
> + return &w->stats.obj_stats;
> + case 'i':
> + return &w->stats.idx_stats;
> + case 'g':
> + return &w->stats.log_stats;
> + }
> + assert(false);
> + return NULL;
> +}As assert() turns into nothing, this is not a particularly good way to document that "if control reaches here, that means we found a programming error".
We intead would use BUG("message") in our codebase, which is marked as NORETURN (so "return NULL" after it would be a dead code).
Thanks.