-
Feature Articles
- Most Recent Articles
- The Easy No
- Flushed Out
- The Hot Fix
- The Roadmap
- Let's Be Facebook!
- Whales Ahoy!
- Three Digit Acronyms
- The Pride Goeth
-
CodeSOD
- Most Recent Articles
- The Error Check
- AAYFN
- Module Test
- On Hold
- The Most Dangerous Game
- Off the Path
- Authorized Logger
- Do a Lot to Do Nothing
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Edit Admin
It IS a WTF, because it doesn't handle FILE_NOT_FOUND!
Edit Admin
TRWTF is writing
==FALSEinstead of!Admin
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).
Admin
Is the long-time developer's name Paula?
Admin
good one
Admin
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().
Admin
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
Admin
For me in C it feels quite common to do it like that.
In Unix/Linux development there is
errno, on Windows we gotGetLasterror.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...
Edit Admin
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
erroris the opposite of what the variable name means.Edit Admin
They handle an error if the error flag is FALSE?!
Edit Admin
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" ?
Edit Admin
Well, they call the variable
error, but it's reallyresultor honestlysuccess. It's a badly named variable, not a full on backwards logic.