News for hackers. Stuff that matters.
Re:The Meaning of 'su' by joshguthrie on Sunday February 24, 2013 @10:01PM (#5277087)
TL;DR: Legacy code with gotos in it.
Re:The Meaning of 'su' by dwyer on Sunday February 24, 2013 @10:19PM (#5277143)
Way to nitpick about goto while completely overlooking the obvious buffer overflow.
Re:The Meaning of 'su' by jrockway on Monday February 25, 2013 @05:06AM (#5278142)
This was all I could think about when reading that code.
Re:The Meaning of 'su' by jeltz on Monday February 25, 2013 @10:37AM (#5279393)
There are at least two buffer overflows in that code.
Re:The Meaning of 'su' by UnoriginalGuy on Monday February 25, 2013 @04:31AM (#5278059)
It is C, of course it is going to have goto's in it. How else are you going to handle error conditions? Copy and paste the error code a dozen times within a single function?

(hint: C doesn't support exceptions)

You could use longjmp/setjmp but those have a lot of the same issues that people claim goto has. In fact worse in several ways, since while goto makes it hard to follow the program flow, longjmp makes it /impossible/.

Re:The Meaning of 'su' by joshguthrie on Monday February 25, 2013 @06:54AM (#5278485)
No exceptions? What a conondrum I find myself faced with...

What about this snippet:

    if (error_return) {
       printf("My error");
       return;
    }
Clearer than a goto, no? And see, no exceptions ma'!

(Oh yeah, and longjmp/setjmp are the worst ideas in the world...)

Re:The Meaning of 'su' by derleth on Monday February 25, 2013 @04:45AM (#5278096)
> since while goto makes it hard to follow the program flow, longjmp makes it /impossible/.

Only if you don't use it tastefully. It can be a nice way to bail out of a recursive function with an error code, which is precisely how I've used it. Really, it looks exactly the same as a try ... catch block in that C++/Java/C# language everyone's on about now.

Re:The Meaning of 'su' by 4ad on Monday February 25, 2013 @04:49AM (#5278101)
Setjmp is great for reseting a state machine, and many things are modeled as state machine.
Re:The Meaning of 'su' by metaphorm on Monday February 25, 2013 @02:05AM (#5277714)
thats not an inappropriate use of gotos either. they're in the same function, just a few lines down, and are just used to improve the safety and efficiency of the code. in fact thats the textbook case of the only time when a goto is actually a good idea.