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);
> }
>>>
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!