LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Re: [linux-edu] war games?

[ILUG] Re: [linux-edu] war games?

Paul Jakma paulj at itg.ie
Wed Jun 21 17:03:36 IST 2000


nice. must remember that one. :)

am i right in thinking that to do the below without goto would be
difficult to do legibly?

ie goto enhances readibility/structure of this?

On Wed, 21 Jun 2000, Mark Fallon wrote:

> Hi,
> 
> Another way goto's are used in the kernel to handle errors is 
> when more than one resource is needed e.g:
> 
> int some_kernel_func(){
>   if (get_res1() != 0){
>     err = ERRRES1;
>     goto err_exit;
>   }
>   if (get_res2() != 0){
>     err = ERRRES2;
>     goto err_exit_res1;
>   }
>   if (get_res3() != 0){
>     err = ERRRES3;
>     goto err_exit_res2;
>   }
> 
> 
> ...
> 
> 	Do something interesting (TM)
> 
> 
> ....
> 
>   err = SUCCESS;
>   release_res3();
> 
> err_exit_res2:
>   release_res2();
> 
> err_exit_res1:
>   release_res1();
> 
> err_exit:
>   return(err);
> }
> 
> 
> 





More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell