Definite case in point. To do this otherwise would require very bold
illegible code and excessive instruction execution cycles. Usually though
waiting on resources is usually covered by an OS API so you should be using
that instead of writing your own.
Noel
> -----Original Message-----
> From: Paul Jakma [mailto:paulj at itg.ie]
> Sent: Wednesday, June 21, 2000 5:03 PM
> To: Mark Fallon
> Cc: ilug at linux.ie> Subject: Re: [ILUG] Re: [linux-edu] war games?
>>> 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);
> > }
> >
> >
> >
>>> --
> Irish Linux Users' Group: ilug at linux.ie>http://www.linux.ie/mailman/listinfo/ilug for
> (un)subscription information.
> List maintainer: listmaster at linux.ie>
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!