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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Han-Wen Nienhuys via GitGitGadget" <gitgitgadget@xxxxxxxxx> 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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux