[MPlayer-dev-eng] [PATCH] libbs2b audio filter

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Mar 28 15:30:59 CET 2009


On Sat, Mar 28, 2009 at 06:21:35AM +0300, Andrew Savchenko wrote:
> I admit, in rare cases goto is a good solution, but not it this 
> one. Please note: cleanups with all sanity checks are already 
> implemented as uninit functions. So IMO the best solution in 
> particular case of libaf will be to call uninit function if an 
> appropriate error code from af_open is returned. Perhaps the best 
> choise for return code will be AF_FATAL due to severe nature of 
> memory allocation problems. However, special code of mask like 
> AF_CLEANUP may be introduced.

Seems like pointless obfuscation to me, you can just call uninit()
before returning, that already solves most maintenance issues (and I
already suggested it), it has two issues though:
1) making uninit able to correctly free a partially initialized context
may be overkill when it is much simpler to implement with gotos.
2) you can not free local variables like this (nor with your
suggestion), so as soon as you need temporary storage in your init
function all those maintenance issues return again.
Alternatively it makes some people resolve to idiocies like putting
several-MB sized arrays on the stack.

Neither apply to this specific case, so I fully admit that the only
argument for "goto" here is that it is the "works in general" solution
instead of the "works in this case, for now" solution, which is a
rather weak one.
Anyway, I think we do not disagree (much), it's just that you sounded a bit
like you'd refuse to use goto even in cases where it is an easy way to
make the code vastly simpler.
That would be an attitude I would prefer to rid everyone of :-).



More information about the MPlayer-dev-eng mailing list