lkml.org 
[lkml]   [1999]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: goto's ???
  Hello.

> struct file *filp_open(const char * filename, int flags, int mode)
> {
> struct inode * inode;
> struct dentry * dentry;
> struct file * f;
> int flag,error;
>
> error = -ENFILE;
> f = get_empty_filp();
> if (!f)
> goto out;
> ....
> <SNIP>
>
> out:
> return ERR_PTR(error);
> }
>
> this seems like an extra jmp statement to me (unless the compiler
> optimises it)
>
> ie why not just do this :
> struct file *filp_open(const char * filename, int flags, int mode)
> {
> struct inode * inode;
> struct dentry * dentry;
> struct file * f;
> int flag,error;
>
> error = -ENFILE;
> f = get_empty_filp();
> if (!f)
> return ERR_PTR(error);
> ....
> <SNIP>
> }
The way used is a bit more generic - ie. if you later find out that you
need to release some lock or so, you just add it there and can be happy. Otherwise
you have to change the code and probably miss some case :-). And I think
that gcc is clever enough to optimize the jumps...

Honza.


-
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:51    [from the cache]
©2003-2011 Jasper Spaans