[lkml]   [2003]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: Style question: Should one check for NULL pointers?
    Hua Zhong wrote:

    > Not always true. In some cases you know how to handle: just return
    > without doing anyting.

    That is NOT an error condition - the API specifically allows NULL to be
    passed in, and specifically states that no action will be taken in that

    But consider the following code:


    That IS an error condition - both the string to scan and the format
    string are NULL. In this case sscanf should return EITHER 0 (no items
    matched) or better still -1 (error).

    As others have said - ideally, if you have any doubt about a new
    function you are writing being able to succeed, you should write it to
    return a success report.

    However, my whole point was that simply checking for null and doing
    nothing when null was not a valid value was violating the rule of "don't
    check if you don't know how to handle".

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:46    [W:0.020 / U:10.996 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site