lkml.org 
[lkml]   [1999]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: oom() _still_ killing init
Last time I checked GCC, your proposed style generated worse code -- it
had branches in the fast path and extra tests.

[And it's ugly IMO]

-- Jamie

Oliver Xymoron wrote:
> foo(<vars>)
> {
> ....
> if(something_bad)
> goto fail;
> ....
> fail:
> /* do cleanup */
> }
>
> ...with lots of failure modes. These can be trivially transformed to:
>
> foo(<vars>)
> {
> int cleanup_var;
>
> if(!bar(<vars>,&cleanup_var))
> /* do cleanup */
> }
>
> int bar(...)
> {
> int local_vars_we_don't_need_to_clean_up;
> ...
> if(something_bad)
> return 0;
> ...
>
> return 1; /* success */
> }
>
> Throw inline in front of foo_attempt() and you do away with the call
> overhead. I'm not presenting this as an ideal approach, just an existence
> proof that eliminating gotos is not necessarily hard, nor need it result
> in ridiculous nesting. It may in fact result in smaller and simpler
> functions.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:52    [W:0.046 / U:0.804 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site