Hi,
Does existence of "goto" in a code enough to brand it as bad code???
Consider this piece of code:
short some_function( short arg1 )
{
short return_code = 0;
short ret_code = 0;
ret_code = function_a( arg1 );
if ( ret_code != 0 )
{
// failed...
return_code = ret_code;
goto fexit;
}
ret_code = function_b();
if ( ret_code != 0 )
{
// failed...
return_code = ret_code;
goto fexit;
}
....
....
....
fexit:
if ( return_code != 0 )
{
// release all hogged resources, do necessary cleanup...
}
return ( return_code );
} // end of some_function()
Would you consider the above code bad?
The indentation would probably go haywire, but consider it properly indented :-)
Thanks,
- Ruchikar.