Hi, I read that both multiple returns and multiple goto statements are bad programming practice. I have a function which can detect some 8 types of errors. In case of error, should i return error code or should i use goto statment to go to end of function and return from there. Whenever memory freeing is required before returning from function, i thought it would be better to have a goto end and free the memory at the end of the function(so that only one free is enough in function)
However, In my function, memory is not allocated. In this case which one is preferable ? Multiple returns or multiple goto statements ? Or can we avoid both ?
EDIT: Some way to avoid both is, pass parameter to function which can store errorType. Samething can be checked inside function before proceeding further. But this too makes the code ugly.