lkml.org 
[lkml]   [2004]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    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
    following:

    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?

    Chris
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 14:07    [W:0.019 / U:30.440 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site