Thread (1 message) 1 message, 1 author, 2020-02-06

Re: [PATCH v4 4/5] Add reftable library

From: Junio C Hamano <hidden>
Date: 2020-02-06 23:07:06

"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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help