[lkml]   [2007]   [Aug]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: kfree(0) - ok?

    On Aug 15 2007 09:58, Kyle Moffett wrote:
    > Irrespective of whatever the standard says, EVERY platform and
    > compiler anybody makes nowadays has a NULL pointer value with all
    > bits clear. Theoretically the standard allows otherwise, but such
    > a decision would break so much code. Linux especially, we rely on
    > the uninitialized data to have all bits clear and we depend on that
    > producing NULL pointers; if a NULL pointer was not bitwise exactly
    > 0 then the test "if (some_ptr != NULL)" would fail and we would
    > start dereferencing garbage.

    But if kmalloc returns NULL on failure, then testing for NULL
    (irrespective of being 0 or 0xDEADBEEF) is ok.
    What would actually concern me then is what "if (!some_ptr)" would do.
    Probably not the right thing.

    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: 2007-08-15 16:09    [W:0.021 / U:69.744 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site