Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Use goto

Name: Anonymous 2012-09-17 19:14

I'm using goto outside assembly and there's nothing you can do about it, meanwhile your jewish teachers gave your looping toys and forbid faster code for you.

Name: Anonymous 2012-09-17 23:30

Very common idiom in kernel code:

int foo(int x)
{
    int status = 0;
       
    (void) bar(x);

    if (0 != baz(x)) {
        status = -1;
        goto out1;
    }
   
    (void) qux(x);
out1:
    unbar(x);
    return status;
}


This saves writing a stub function just to break out and unbar if baz fails.

Name: Anonymous 2012-09-17 23:35

>>12

I've used goto before, but it isn't that necessary here.


int foo(int x)
{
    int status = 0;
      
    (void) bar(x);

    if (baz(x) == 0)
    {
      (void) qux(x);
    }
    else
    {
      status = -1;
    }
    unbar(x);
    return status;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List