• An Old Hacker (unregistered)

    [NULL, 'frist', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]

  • P-Well (unregistered)

    "There are layers upon layers upon layers here."

    • Dan Kennedy
  • 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. :(

  • Bogolese (unregistered)

    TRWTF is WTF is it?

  • BlackBart (unregistered) in reply to Bogolese
    Bogolese:
    TRWTF is WTF *is* it?

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

  • (cs)

    Looks like a function pointer list that is only partially filled in this case.

  • (cs)

    Objects? We don't need no stinkin' Objects.

  • SG_01 (unregistered)

    TRWTF is un-'typedef'ed function pointer arrays ^^

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

  • TGVish (unregistered) in reply to Bogolese
    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!
  • Ben (unregistered)

    So.. you have a lookup table to call a function depending on an opcode. How is this a WTF?

  • 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
    };
    
  • 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

  • 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?

  • Anon (unregistered)

    NULL, NULL, NULL, RAT, and NULL

  • (cs)

    Inside each small problem is a bigger one waiting to get out.

  • MadX (unregistered)

    Whoa, Nully.

  • 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.
  • SeySayux (unregistered) in reply to An Old Hacker
    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.

  • (cs)

    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.

  • Migala (unregistered) in reply to MadX
    MadX:
    Whoa, Nully.

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

  • anonymouse (unregistered) in reply to allen-poole.com
    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.

  • Anon (unregistered) in reply to Anon

    Do you have something without so much NULL in it?

  • Belgarion (unregistered)

    It looks like vanulla array initialization to me.

  • SnatchThePebblesFromMyHand (unregistered) in reply to herp derp

    "Assemblies" in 1998? You're not fooling me, young grasshopper.

  • (cs) in reply to Belgarion
    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.
  • frits (unregistered)

    Who hasn't done something like this?

  • Patrick (unregistered) in reply to SeySayux

    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]

  • Hat Trick (unregistered) in reply to anonymouse
    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.

  • whatamess (unregistered)

    Seriously, anyone who thinks there isn't something inherently wrong with this code should change profession... you are hurting the industry!

  • boog (unregistered)

    I'm pretty sure I would have strangled the penguin before I got to the 4th NULL.

  • (cs) in reply to frits
    frits:
    Who hasn't done something like this?

    Not me, for sure.

  • (cs) in reply to boog
    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?

  • frits (unregistered) in reply to boog
    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?

  • Gaddafi (unregistered)

    Looks a little like a Python C extension.

  • " DROP TABLE USERS; " (unregistered) in reply to whatamess
    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.

  • Shiva (unregistered) in reply to Nagesh
    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.

  • Nagesh (unregistered) in reply to Shiva
    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.

  • no2trolls (unregistered) in reply to Anon
    Anon:
    Do you have something without so much NULL in it?

    I'll have your NULL. I love it.

  • (cs) in reply to Anon
    Anon:
    Do you have something without so much NULL in it?

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

    Bloody Vikings!

  • (cs) in reply to whatamess
    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.)

  • (cs) in reply to C3PO
    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.

  • (cs)

    Looks like a state machine to me. One with only a few states...

  • (cs) in reply to Hat Trick
    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.

  • (cs) in reply to Shiva
    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.

  • #TDWTFMafia #SOMafia (unregistered) in reply to Nagesh
    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!

  • Aaron Rogers (unregistered) in reply to JamesQMurphy
    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.
  • (cs)

    #define NULL 1337

    Then watch the shit storm fly.

  • frits (unregistered) in reply to Pr0gramm3r
    Pr0gramm3r:
    #define NULL 1337

    Then watch the shit storm fly.

    Who hasn't done something like this?
  • (cs)

    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.

Leave a comment on “The Interface”

Log In or post as a guest

Replying to comment #:

« Return to Article