5 ms·
A NULL head is not an error (= empty list) and 'assert' would be better as a BUG_ON or panic if it is technically an error.
by eatbitseveryday 10y ago
A NULL head is not an error (= empty list) and 'assert' would be better as a BUG_ON or panic if it is technically an error.
- deleted 10y ago[deleted]
- avip 10y agoIt is an error though if your code SEGFAULT on NULL head (and this one does). I wouldn't care, but if you claim to be defensive, go full monty.
- eatbitseveryday 10y ago> It is an error though if your code SEGFAULT on NULL head (and this one does). There is no "SEGFAULT" in kernel code. SIGSEGV is a signal, which is only used at user-level. NULL dereference in the kernel results in an "oops". I believe it is also assumed in their code that "entry" is not going to be NULL, meaning "if (head == entry)" will never succeed if head is NULL.
- avip 10y agoThe code crashes if head is NULL, regardless of entry.