- Feature Articles
- CodeSOD
- 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
Admin
[NULL, 'frist', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
Admin
"There are layers upon layers upon layers here."
Admin
The bad thing about reading so early in the morning is that the funny comments have not yet arrived. :(
Admin
TRWTF is WTF is it?
Admin
ECU -> Engine Control Unit. Gotta have 255 test cases to make sure there's no unintended acceleration!
Admin
Looks like a function pointer list that is only partially filled in this case.
Admin
Objects? We don't need no stinkin' Objects.
Admin
TRWTF is un-'typedef'ed function pointer arrays ^^
Admin
"Apparently, this structure is essential for passing information to other layers. Now if I only knew how it's supposed to do that..."
Problem 1: That's not a structure, though it probably should have been one.
Admin
Admin
So.. you have a lookup table to call a function depending on an opcode. How is this a WTF?
Admin
I think I see the pattern there. Here, fixed the 5 bugs for you.
Admin
oh, the joys of maintaining legacy applications.
nothing like having to troubleshoot and debug applications which are used everyday by everyone in the company to find errors which are deep within an assembly with the most recent comments dating back to 1998. even better when it is all in VB6 and recompiling one assembly means having to recompile everything else which references it, upwards of 15 other assemblies and related applications. sigh
Admin
Obviously, Brian does not understand C. He probably thinks it's like Java™, where references new arrays are initialized to [n]null[/b] or 0 (depending on type) automatically. In C, if you initialize a structure, it is filled with random bits and bytes. This could be a sparse array or a fixed-state machine, which should in either case contain a valid base-case value.
I would think that a "real" C programmer would just use 0 here, but maybe that is TRWTF?
Admin
NULL, NULL, NULL, RAT, and NULL
Admin
Inside each small problem is a bigger one waiting to get out.
Admin
Whoa, Nully.
Admin
Layers just makes me think of Shrek
Admin
Your use of python arrays in this context amuses me slighty, as it does confirm your sterotype as a dimwit.
Admin
Ok, the arrangement of entries is a little wanked, mostly because the names of the functions aren't the same length in the source code as NULL is, but there's nothing particularly wrong with this.
The declaration is confusing because, although it is accurately declared as an array of constant pointers to functions receiving const u8 * and (const) u16 and returning void, it is unusual to see an array of function pointers declared in a single step like this. I wrote my first C program 26 years ago (and have been writing them ever since, as well as C++, Fortran, assembler, Pascal, VB, Python, OPL, and a few other oddments), and it took me a moment to work out where the "const" was supposed to be binding.
Other than that, and a lack of hint comments showing what the programmer thinks the indexes are, it's not so bad.
Admin
+1. Was just listening to her (not that album, but still).
Admin
Oh darn, someone beat me to the Shrek reference. This was the first thing that came to mind when I saw today's wtf.
Admin
Do you have something without so much NULL in it?
Admin
It looks like vanulla array initialization to me.
Admin
"Assemblies" in 1998? You're not fooling me, young grasshopper.
Admin
Admin
Who hasn't done something like this?
Admin
Well if you want a python array it would be None, not NULL.
Unless you did something like:
NULL = None [NULL, 'not_frist', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
Admin
Admin
Seriously, anyone who thinks there isn't something inherently wrong with this code should change profession... you are hurting the industry!
Admin
I'm pretty sure I would have strangled the penguin before I got to the 4th NULL.
Admin
Not me, for sure.
Admin
What is strangling the penguin? Is this a BATMAN reference?
Admin
Your not too bright, are you?
Admin
Looks a little like a Python C extension.
Admin
It's just initializing a sparse vtable, looks like. On an embedded system (in this case, a vehicle ECU), etc. etc.
Admin
Admin
Really? Wow. I was off for two days to celebrate the dead Presidents of America.
Admin
I'll have your NULL. I love it.
Admin
Cue the Vikings, singing, "NULL null null null NULL null..."
Bloody Vikings!
Admin
Me, I would have included a no-action function to avoid littering the code with if( function pointer from table is not NULL ) before each call. If the live actions are truly this sparse, though, and there is just 'one' point-of-call, I'd have written a switch() to dispatch instead. The boundary between "wants a switch for clarity" and "wants a dispatch table for clarity" is very fuzzy, and depends on many hard-to-quantify things.
With access to an OO language, the response is different, of course, although this level of sparseness suggests a high probability of weak factoring. (I know you can build an OO system in non-OO languages, but the scope for hard-to-find bugs is just amazing.)
Admin
FTFY.
Admin
Looks like a state machine to me. One with only a few states...
Admin
%s/normal/childless/g
I can assure you - most parents with a child born after 1990 thought Shrek.
Admin
Idiot, Nobody has hacked my account. THere's one stalkher I have acquired, who insists on using my good name.
Admin
One? We are legion and the coolest!
Admin
Admin
#define NULL 1337
Then watch the shit storm fly.
Admin
Admin
It looks like more work from this guy. But today's code appears to be a step up from the other method. That is, at least he's not using a case statement.
That we can see.