Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'd add something like

    assert (head && entry)
up there.


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.


It 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.


> 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.


The code crashes if head is NULL, regardless of entry.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: