• (nodebb)

    It IS a WTF, because it doesn't handle FILE_NOT_FOUND!

  • (nodebb)

    TRWTF is writing ==FALSE instead of !

  • Greg (unregistered)

    Makes you wonder why they don't return the error code in the first place instead of storing the error somewhere (very likely in some global variable) and returning a BOOL (which in C-land is just an int).

  • Michael R (unregistered)

    Is the long-time developer's name Paula?

  • new arrival (unregistered) in reply to Michael R

    good one

  • Rob (unregistered) in reply to Greg

    Makes you wonder why they don't return the error code in the first place instead of storing the error somewhere (very likely in some global variable) and returning a BOOL (which in C-land is just an int).

    The GetLastError() is a giveaway that this is most likely a Windows API call, which uses the "return false and check GetLastError() afterwards" convention a lot. Fortunately GetLastError() it's thread-safe.

    Note that Unix / Linux also follow this convention a lot. There's the (thread) global errno variable that serves the same purpose as GetLastError().

  • some guy, also expert (unregistered)

    They don't change the code, the code changes them.

    Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.

    -- nickm_tor, apparently

  • f222 (unregistered) in reply to Greg

    For me in C it feels quite common to do it like that.

    In Unix/Linux development there is errno, on Windows we got GetLasterror.

    I'm not saying it's the right thing to do but it's definitely a common idiom: If you don't need details about the error, your code will have nothing to do with the details of the error...

  • (nodebb)

    Unless I'm misreading it because it's still early in the morning (a.k.a. before noon), this is definitely a WTF. If there isn't an error, it handles the error. Or the value of error is the opposite of what the variable name means.

  • (nodebb)

    They handle an error if the error flag is FALSE?!

  • (nodebb)

    This feels even more screwy because if you started with "functions return an int, 0 is success, anything else a failure denoted by the value (or you need to look in errno)", and factor in that int 0 is falsey, and any other value truthy, then surely the error case would be "error == TRUE" ?

  • (author) in reply to Dragnslcr

    Well, they call the variable error, but it's really result or honestly success. It's a badly named variable, not a full on backwards logic.

  • (nodebb) in reply to Remy Porter

    Then the "annoying" convention and the "standard" convention are the same, except that the annoying convention names the variable the exact opposite of what the value means?

    Sure, we've seen worse, and we've seen this one many times, but it's definitely a WTF.

  • Scragar (unregistered) in reply to Rob
    Comment held for moderation.
  • Scragar (unregistered) in reply to Rob
    Comment held for moderation.
  • Anonymous Coward (unregistered)
    Comment held for moderation.
  • Brian (unregistered)
    Comment held for moderation.
  • Hmmmm (unregistered)
    Comment held for moderation.

Leave a comment on “The Error Check”

Log In or post as a guest

Replying to comment #701946:

« Return to Article