Representative line, part int.MaxValue



  • for (int x = 0; x < 1; x++)
    {
      StartService(x);
    }

    I checked the version history. This code was checked in like this. QAs FTW.




    [mod - botched attempt at posting unescaped code fixed - PJH]


  • Just to be sure; we're talking about half a statement here, right? In that case: WTF!?!

    [Edit] Nevermind, Ninja'd by moderator. Okay, looked at the whole thing, and the WTF!?! still stands...



  • Let's use a loop that we know will only ever execute one time ... because ... we can't use a switch statement.


  • ♿ (Parody)

    @The_Assimilator said:

    for (int x = 0; x < 1; x++)
    {
    StartService(x);
    }

    HTRWTFFY



  • @The_Assimilator said:

    I checked the version history. This code was checked in like this. QAs FTW.
     

    Pf.

    At least your loop has any code at all in its body.



  • Perhaps this is C, and the author meant it as a way to parameterize how many times the service starts:

    #define 1 30



  • Posting test, test test test



  • @zelmak said:

    Let's use a loop that we know will only ever execute one time ... because ... we can't use a switch statement.

    Because we can't use
    Run(0)?


  • @Sutherlands said:

    @zelmak said:

    Let's use a loop that we know will only ever execute one time ... because ... we can't use a switch statement.

    Because we can't use
    Run(0)?

    I think Zelmak meant that we can't do this:

    @The_Assimilator said:

    for (int x = 0; x < 1; x++)
    {
    switch (x)
    {
    case 0:
    StartService(x);
    break;
    }
    }

    Adding a default case that returns FILE_NOT_FOUND is left as an exercise for the real wtf reader.



  • I have made similar mistakes to this before; however, before I check my code into source control I review it and fix these kinds of oops.  In my case how it would happen is when I would be attempting something new and would be writing a ton of new code, and then I would have the "Oh! I am such an idiot" moment and start mass deleting and fixing, and in the process of mass deleting a loop or if that served a purpose got nerfed but not deleted. 



  • @The_Assimilator said:

     

    for (int x = 0; x < 1; x++)
    {
      StartService(x);
    }

    I checked the version history. This code was checked in like this. QAs FTW.

    Just out of curiosity, what does StartService do with the input parameter?  Maybe it'll shed some light on the thought process behind the original code.

    (My best guess would be that that upper limit was at some point a number other than one, as some kind of retry mechanism.  Maybe the committer thought it might perhaps be needed again at some future point.  It's a pretty sure thing you can rely on the compiler to optimise a loop as simple as that.)



  • @DaveK said:

    @The_Assimilator said:

     

    for (int x = 0; x < 1; x++)
    {
      StartService(x);
    }

    I checked the version history. This code was checked in like this. QAs FTW.

    Just out of curiosity, what does StartService do with the input parameter?  Maybe it'll shed some light on the thought process behind the original code.

    (My best guess would be that that upper limit was at some point a number other than one, as some kind of retry mechanism.  Maybe the committer thought it might perhaps be needed again at some future point.  It's a pretty sure thing you can rely on the compiler to optimise a loop as simple as that.)

     

    Pay attention.  Ask yourself, how many times will this loop run?

    Note: the value stored in variable x is being passed to the function by value.

     



  • @hoodaticus said:

    @DaveK said:

    @The_Assimilator said:

     

    for (int x = 0; x < 1; x++)
    {
    StartService(x);
    }

    I checked the version history. This code was checked in like this. QAs FTW.

    Just out of curiosity, what does StartService do with the input parameter?  Maybe it'll shed some light on the thought process behind the original code.

    (My best guess would be that that upper limit was at some point a number other than one, as some kind of retry mechanism.  Maybe the committer thought it might perhaps be needed again at some future point.  It's a pretty sure thing you can rely on the compiler to optimise a loop as simple as that.)

     

    Pay attention.  Ask yourself, how many times will this loop run?

    Note: the value stored in variable x is being passed to the function by value.

     

    No, you pay attention; we've already been through all that, the point of my post was to see if we could infer from what usage the StartService() declaration (edit: or definition) makes of that argument, whether or not it might have made sense for it to at any point range over a value other than zero to zero.   As I said in my post above.


  • :belt_onion:

    @DaveK said:

    @Sutherlands said:

    @zelmak said:

    Let's use a loop that we know will only ever execute one time ... because ... we can't use a switch statement.

    Because we can't use
    Run(0)?

    I think Zelmak meant that we can't do this:

    @The_Assimilator said:

    for (int x = 0; x < 1; x++)
    {
    switch (x)
    {
    case 0:
    StartService(x);
    break;
    }
    }

    Adding a default case that returns FILE_NOT_FOUND is left as an exercise for the real wtf reader.

    Shirley it should be

    [code]for (int x = 0; x < 1; StartService(x++));[/code]


  • @bjolling said:

    @DaveK said:

    @Sutherlands said:

    @zelmak said:

    Let's use a loop that we know will only ever execute one time ... because ... we can't use a switch statement.

    Because we can't use
    Run(0)?

    I think Zelmak meant that we can't do this:

    @The_Assimilator said:

    for (int x = 0; x < 1; x++)
    {
    switch (x)
    {
    case 0:
    StartService(x);
    break;
    }
    }

    Adding a default case that returns FILE_NOT_FOUND is left as an exercise for the real wtf reader.

    Shirley it should be

    <font face="Lucida Console" size="2">for (int x = 0; x < 1; StartService(x++));</font>

    Not if you wanted it to be an example of "The FOR-CASE paradigm".  Which I did, because that was my guess what Zelmak was referring to.




  • @DaveK said:

    @hoodaticus said:

    @DaveK said:

    @The_Assimilator said:

     

    for (int x = 0; x < 1; x++)
    {
    StartService(x);
    }

    I checked the version history. This code was checked in like this. QAs FTW.

    Just out of curiosity, what does StartService do with the input parameter?  Maybe it'll shed some light on the thought process behind the original code.

    (My best guess would be that that upper limit was at some point a number other than one, as some kind of retry mechanism.  Maybe the committer thought it might perhaps be needed again at some future point.  It's a pretty sure thing you can rely on the compiler to optimise a loop as simple as that.)

     

    Pay attention.  Ask yourself, how many times will this loop run?

    Note: the value stored in variable x is being passed to the function by value.

     

    No, you pay attention; we've already been through all that, the point of my post was to see if we could infer from what usage the StartService() declaration (edit: or definition) makes of that argument, whether or not it might have made sense for it to at any point range over a value other than zero to zero.   As I said in my post above.

    Oh, and another thing: what makes you think you can be sure that x *is* being passed by value, anyway?  This could be C++ just as easily as C.  Nothing the OP has told us suggests either way, unless I missed something.




  • @DaveK said:

    Oh, and another thing: what makes you think you can be sure that x is being passed by value, anyway?  This could be C++ just as easily as C.  Nothing the OP has told us suggests either way, unless I missed something.

    Maybe it's passed by reference and StartService() resets the value to 0 each time. Then we'd have an infinite loop.



  • @morbiuswilters said:

    @DaveK said:
    Oh, and another thing: what makes you think you can be sure that x *is* being passed by value, anyway?  This could be C++ just as easily as C.  Nothing the OP has told us suggests either way, unless I missed something.

    Maybe it's passed by reference and StartService() resets the value to 0 each time. Then we'd have an infinite loop.

    Maybe StartService() sets it to zero on failure and greater than zero on success.  Then it would be almost sane.  Not actually sane, but almost sane.



Log in to reply