"Han-Wen Nienhuys via GitGitGadget" [off-list ref] writes:
+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.