News for hackers. Stuff that matters.
Re:Linus Torvalds' good taste argument for linked lists, exp... by scoutt on Monday December 07, 2020 @08:40AM (#25332000)
It's a bad idea, especially in kernel/low-level/performant code. It's OK to check some values at specific points (like when a value is passed from user space), but in general it's bad practice to check it at every single function. You trust in your program flow.

Imagine if at every function down a complex stack you go with:

    if (!ptr1 || !*ptr1 || *ptr1 > 5 || param1 < 0 || param2)
        /* etc.... */
    {
        return NULL;
    }
(used arbitrary names and values).

There are no comments on this comment yet.