[lkml]   [2004]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Subjectquestion on common error-handling idiom

    There's something I've been wondering about for a while. There is a lot of code
    in linux that looks something like this:

    err = -ERRORCODE
    if (error condition)
    goto out;

    While nice to read, it would seem that it might be more efficient to do the

    if (error condition) {
    err = -ERRORCODE;
    goto out;

    Is there any particular reason why the former is preferred? Is the compiler
    smart enough to optimize away the additional write in the non-error path?

    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 14:07    [W:0.022 / U:219.496 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site