Comment On The Interface

"I was (once again) re-assigned to another old project for upkeep 'n such," Johnny D writes, "and as it so happened, there was a bug. " [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5Next »

Re: The Interface

2011-02-23 09:03 • by An Old Hacker (unregistered)
[NULL, 'frist', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]

Re: The Interface

2011-02-23 09:05 • by P-Well (unregistered)
"There are layers upon layers upon layers here."
- Dan Kennedy

Re: The Interface

2011-02-23 09:08 • by A. Cow Ard, the 3rd (unregistered)
The bad thing about reading so early in the morning is that the funny comments have not yet arrived. :(

Re: The Interface

2011-02-23 09:09 • by Bogolese (unregistered)
TRWTF is WTF *is* it?

Re: The Interface

2011-02-23 09:11 • by BlackBart (unregistered)
338795 in reply to 338794
Bogolese:
TRWTF is WTF *is* it?


ECU -> Engine Control Unit. Gotta have 255 test cases to make sure there's no unintended acceleration!

Re: The Interface

2011-02-23 09:19 • by henke37
Looks like a function pointer list that is only partially filled in this case.

Re: The Interface

2011-02-23 09:19 • by ooblek
Objects? We don't need no stinkin' Objects.

Re: The Interface

2011-02-23 09:19 • by SG_01 (unregistered)
TRWTF is un-'typedef'ed function pointer arrays ^^

Re: The Interface

2011-02-23 09:21 • by IronMensan (unregistered)
"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.

Re: The Interface

2011-02-23 09:22 • by TGVish (unregistered)
338800 in reply to 338794
Bogolese:
TRWTF is WTF *is* it?

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!

Re: The Interface

2011-02-23 09:22 • by Ben (unregistered)
So.. you have a lookup table to call a function depending on an opcode. How is this a WTF?

Re: The Interface

2011-02-23 09:22 • by Cyp (unregistered)
I think I see the pattern there. Here, fixed the 5 bugs for you.


static void (*const SID[MAX_NUM_SERVICE_IDENTIFIERS])
( const u8 *data, const u16 bytes ) =
{
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL,
NULL, NULL,NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL
};

Re: The Interface

2011-02-23 09:30 • by herp derp (unregistered)
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*

Re: The Interface

2011-02-23 09:31 • by C3PO (unregistered)
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?

Re: The Interface

2011-02-23 09:33 • by Anon (unregistered)
NULL, NULL, NULL, RAT, and NULL

Re: The Interface

2011-02-23 09:34 • by Nagesh
Inside each small problem is a bigger one waiting to get out.

Re: The Interface

2011-02-23 09:38 • by MadX (unregistered)
Whoa, Nully.

Re: The Interface

2011-02-23 09:39 • by allen-poole.com (unregistered)
Layers just makes me think of Shrek

An ogre is like an onion.
They stink?
Yes... NO!
Oh, they make you cry?
No!
Oh, you leave 'em out in the sun, they get all brown, start sproutin' little white hairs...
NO! Layers. Onions have layers. Ogres have layers. Onions have layers. You get it? We both have layers.

Re: The Interface

2011-02-23 09:39 • by SeySayux (unregistered)
338809 in reply to 338791
An Old Hacker:
[NULL, 'frist', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]


Your use of python arrays in this context amuses me slighty, as it does confirm your sterotype as a dimwit.

Re: The Interface

2011-02-23 09:42 • by Steve The Cynic
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.

Re: The Interface

2011-02-23 09:43 • by Migala (unregistered)
338811 in reply to 338807
MadX:
Whoa, Nully.


+1. Was just listening to her (not that album, but still).

Re: The Interface

2011-02-23 09:49 • by anonymouse (unregistered)
338812 in reply to 338808
allen-poole.com:
Layers just makes me think of Shrek

An ogre is like an onion.
They stink?
Yes... NO!
...snip...


Oh darn, someone beat me to the Shrek reference. This was the first thing that came to mind when I saw today's wtf.

Re: The Interface

2011-02-23 09:49 • by Anon (unregistered)
338813 in reply to 338805
Do you have something without so much NULL in it?

Re: The Interface

2011-02-23 09:49 • by Belgarion (unregistered)
It looks like vanulla array initialization to me.

Re: The Interface

2011-02-23 09:53 • by SnatchThePebblesFromMyHand (unregistered)
338815 in reply to 338803
"Assemblies" in 1998? You're not fooling me, young grasshopper.

Re: The Interface

2011-02-23 09:55 • by dugginator
338816 in reply to 338814
Belgarion:
It looks like vanulla array initialization to me.

Really? I must not be squinting the right way, 'cause all I can see is a teapot.

Re: The Interface

2011-02-23 09:58 • by frits (unregistered)
Who hasn't done something like this?

Re: The Interface

2011-02-23 09:59 • by Patrick (unregistered)
338819 in reply to 338809
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)
338820 in reply to 338812
anonymouse:
allen-poole.com:
Layers just makes me think of Shrek

An ogre is like an onion.
They stink?
Yes... NO!
...snip...


Oh darn, someone beat me to the Shrek reference. This was the first thing that came to mind when I saw today's wtf.

While most normal people just thought of Inception.

Re: The Interface

2011-02-23 10:03 • by whatamess (unregistered)
Seriously, anyone who thinks there isn't something inherently wrong with this code should change profession... you are hurting the industry!

Re: The Interface

2011-02-23 10:03 • by boog (unregistered)
I'm pretty sure I would have strangled the penguin before I got to the 4th NULL.

Re: The Interface

2011-02-23 10:04 • by Nagesh
338823 in reply to 338818
frits:
Who hasn't done something like this?


Not me, for sure.

Re: The Interface

2011-02-23 10:05 • by Nagesh
338824 in reply to 338822
boog:
I'm pretty sure I would have strangled the penguin before I got to the 4th NULL.


What is strangling the penguin? Is this a BATMAN reference?

Re: The Interface

2011-02-23 10:07 • by frits (unregistered)
338825 in reply to 338822
boog:
I'm pretty sure I would have strangled the penguin before I got to the 4th NULL.

I'm pretty sure you'd go to jail for animal cruelty. Ever heard of Michael Vick?

Your not too bright, are you?

Re: The Interface

2011-02-23 10:07 • by Gaddafi (unregistered)
Looks a little like a Python C extension.

Re: The Interface

2011-02-23 10:08 • by " DROP TABLE USERS; " (unregistered)
338827 in reply to 338821
whatamess:
Seriously, anyone who thinks there isn't something inherently wrong with this code should change profession... you are hurting the industry!


It's just initializing a sparse vtable, looks like. On an embedded system (in this case, a vehicle ECU), etc. etc.

Re: The Interface

2011-02-23 10:08 • by Shiva (unregistered)
338828 in reply to 338824
Nagesh:
boog:
I'm pretty sure I would have strangled the penguin before I got to the 4th NULL.


What is strangling the penguin? Is this a BATMAN reference?

Nagesh, dude, someone hacked your account yesterday.

Re: The Interface

2011-02-23 10:10 • by Nagesh (unregistered)
338829 in reply to 338828
Shiva:
Nagesh:
boog:
I'm pretty sure I would have strangled the penguin before I got to the 4th NULL.


What is strangling the penguin? Is this a BATMAN reference?

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)
338830 in reply to 338813
Anon:
Do you have something without so much NULL in it?


I'll have your NULL. I love it.

Re: The Interface

2011-02-23 10:16 • by JamesQMurphy
338831 in reply to 338813
Anon:
Do you have something without so much NULL in it?


Cue the Vikings, singing, "NULL null null null NULL null..."

Bloody Vikings!

Re: The Interface

2011-02-23 10:16 • by Steve The Cynic
338832 in reply to 338821
whatamess:
Seriously, anyone who thinks there isn't something inherently wrong with this code should change profession... you are hurting the industry!

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.)

Re: The Interface

2011-02-23 10:18 • by imgx64
338833 in reply to 338804
C3PO:
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 think that C is TRWTF?


FTFY.

Re: The Interface

2011-02-23 10:19 • by lyates
Looks like a state machine to me.
One with only a few states...

Re: The Interface

2011-02-23 10:19 • by Code Slave
338835 in reply to 338820
Hat Trick:
anonymouse:
allen-poole.com:
Layers just makes me think of Shrek

An ogre is like an onion.
They stink?
Yes... NO!
...snip...


Oh darn, someone beat me to the Shrek reference. This was the first thing that came to mind when I saw today's wtf.

While most normal people just thought of Inception.


%s/normal/childless/g

I can assure you - most parents with a child born after 1990 thought Shrek.

Re: The Interface

2011-02-23 10:20 • by Nagesh
338836 in reply to 338828
Shiva:
Nagesh:
boog:
I'm pretty sure I would have strangled the penguin before I got to the 4th NULL.


What is strangling the penguin? Is this a BATMAN reference?

Nagesh, dude, someone hacked your account yesterday.


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)
338837 in reply to 338836
Nagesh:
Shiva:
Nagesh:
boog:
I'm pretty sure I would have strangled the penguin before I got to the 4th NULL.


What is strangling the penguin? Is this a BATMAN reference?

Nagesh, dude, someone hacked your account yesterday.


Idiot,
Nobody has hacked my account. THere's one stalkher I have acquired, who insists on using my good name.




One? We are legion and the coolest!

Re: The Interface

2011-02-23 10:24 • by Aaron Rogers (unregistered)
338838 in reply to 338831
JamesQMurphy:
Anon:
Do you have something without so much NULL in it?


Cue the Vikings, singing, "NULL null null null NULL null..."

Bloody Vikings!

I couldn't care less about the Vikings. They can't even make the playoffs.

Re: The Interface

2011-02-23 10:27 • by Pr0gramm3r
#define NULL 1337

Then watch the shit storm fly.

Re: The Interface

2011-02-23 10:36 • by frits (unregistered)
338841 in reply to 338839
Pr0gramm3r:
#define NULL 1337

Then watch the shit storm fly.

Who hasn't done something like this?

Re: The Interface

2011-02-23 10:36 • by boog
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.
« PrevPage 1 | Page 2 | Page 3 | Page 4 | Page 5Next »

Add Comment