| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Page 5 | Next » |
|
[NULL, 'frist', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]
|
|
"There are layers upon layers upon layers here."
- Dan Kennedy |
|
The bad thing about reading so early in the morning is that the funny comments have not yet arrived. :(
|
|
TRWTF is WTF *is* it?
|
Re: The Interface
2011-02-23 09:11
•
by
BlackBart
(unregistered)
|
ECU -> Engine Control Unit. Gotta have 255 test cases to make sure there's no unintended acceleration! |
|
Looks like a function pointer list that is only partially filled in this case.
|
|
Objects? We don't need no stinkin' Objects.
|
|
TRWTF is un-'typedef'ed function pointer arrays ^^
|
|
"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. |
An array with function pointers. You put in an index (probably a service number), and you get a function that you can apply to a string of bytes with its length. Simple! |
|
So.. you have a lookup table to call a function depending on an opcode. How is this a WTF?
|
|
I think I see the pattern there. Here, fixed the 5 bugs for you.
|
|
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* |
|
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? |
|
NULL, NULL, NULL, RAT, and NULL
|
|
Inside each small problem is a bigger one waiting to get out.
|
|
Layers just makes me think of Shrek
|
Re: The Interface
2011-02-23 09:39
•
by
SeySayux
(unregistered)
|
Your use of python arrays in this context amuses me slighty, as it does confirm your sterotype as a dimwit. |
|
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. |
+1. Was just listening to her (not that album, but still). |
Re: The Interface
2011-02-23 09:49
•
by
anonymouse
(unregistered)
|
Oh darn, someone beat me to the Shrek reference. This was the first thing that came to mind when I saw today's wtf. |
|
Do you have something without so much NULL in it?
|
|
It looks like vanulla array initialization to me.
|
Re: The Interface
2011-02-23 09:53
•
by
SnatchThePebblesFromMyHand
(unregistered)
|
|
"Assemblies" in 1998? You're not fooling me, young grasshopper.
|
Really? I must not be squinting the right way, 'cause all I can see is a teapot. |
|
Who hasn't done something like this?
|
Re: The Interface
2011-02-23 09:59
•
by
Patrick
(unregistered)
|
|
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] |
Re: The Interface
2011-02-23 10:03
•
by
Hat Trick
(unregistered)
|
While most normal people just thought of Inception. |
|
Seriously, anyone who thinks there isn't something inherently wrong with this code should change profession... you are hurting the industry!
|
|
I'm pretty sure I would have strangled the penguin before I got to the 4th NULL.
|
Not me, for sure. |
What is strangling the penguin? Is this a BATMAN reference? |
I'm pretty sure you'd go to jail for animal cruelty. Ever heard of Michael Vick? Your not too bright, are you? |
|
Looks a little like a Python C extension.
|
Re: The Interface
2011-02-23 10:08
•
by
" DROP TABLE USERS; "
(unregistered)
|
It's just initializing a sparse vtable, looks like. On an embedded system (in this case, a vehicle ECU), etc. etc. |
Nagesh, dude, someone hacked your account yesterday. |
Really? Wow. I was off for two days to celebrate the dead Presidents of America. |
Re: The Interface
2011-02-23 10:11
•
by
no2trolls
(unregistered)
|
I'll have your NULL. I love it. |
Cue the Vikings, singing, "NULL null null null NULL null..." Bloody Vikings! |
These days I wouldn't *do* it that way, but on the grand scale of things, it is far from the worst possible WTF. In fact, the rest of the system sounds more like a candidate for "significantly worse than this one line of itself", if the number of layers is truly as grotesque as indicated. 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.) |
FTFY. |
|
Looks like a state machine to me.
One with only a few states... |
%s/normal/childless/g I can assure you - most parents with a child born after 1990 thought Shrek. |
Idiot, Nobody has hacked my account. THere's one stalkher I have acquired, who insists on using my good name. |
Re: The Interface
2011-02-23 10:22
•
by
#TDWTFMafia #SOMafia
(unregistered)
|
One? We are legion and the coolest! |
Re: The Interface
2011-02-23 10:24
•
by
Aaron Rogers
(unregistered)
|
I couldn't care less about the Vikings. They can't even make the playoffs. |
|
#define NULL 1337
Then watch the shit storm fly. |
Who hasn't done something like this? |
|
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. |
| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Page 5 | Next » |