GOTOs discovered in "real world" program! (was Re: Error returns and repeated code, GOTOs, etc.)
- From: mike3 <mike4ty4@xxxxxxxxx>
- Date: Thu, 31 May 2012 16:39:28 -0700 (PDT)
On May 29, 11:44 pm, mike3 <mike4...@xxxxxxxxx> wrote:
<snip>
I've made an interesting and disturbing discovery.
I found THIS:
http://www.isc.org/software/bind/991
I decided to have a look at the source code, and oh my goodness! What
did I find?!
Oh NO....!!!!!!!!!!!!!!!!!!!!!!! :
----
idn_result_t
idn_normalizer_add(idn_normalizer_t ctx, const char *scheme_name) {
idn_result_t r;
void *v;
normalize_scheme_t *scheme;
assert(ctx != NULL && scheme_name != NULL);
TRACE(("idn_normalizer_add(scheme_name=%s)\n", scheme_name));
assert(INITIALIZED);
if (idn__strhash_get(scheme_hash, scheme_name, &v) != idn_success) {
ERROR(("idn_normalizer_add(): invalid scheme \"%-.30s\"\n",
scheme_name));
r = idn_invalid_name;
goto ret;
<----------------- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
scheme = v;
assert(ctx->nschemes <= ctx->scheme_size);
if (ctx->nschemes == ctx->scheme_size &&
(r = expand_schemes(ctx)) != idn_success) {
goto ret;
<----------------- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}
ctx->schemes[ctx->nschemes++] = scheme;
r = idn_success;
ret:
<----------------- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
TRACE(("idn_normalizer_add(): %s\n", idn_result_tostring(r)));
return (r);
}
----
YES, that's right -- those are GOTOs in there, and they do this a LOT
in this program! Djikstra!!!
But as this thread seems to show, it looks like that there exist
alternatives
to GOTO, and so we can still uphold Djikstra's law. Or is there
something
about this program that makes it OK to use GOTOs in it, but it is not
OK
to use them in the one I'm doing?
.
- Follow-Ups:
- Prev by Date: Re: Error returns and repeated code, GOTOs, etc.
- Next by Date: Another problem (was Re: Error returns and repeated code, GOTOs, etc.)
- Previous by thread: Re: Error returns and repeated code, GOTOs, etc.
- Next by thread: Re: GOTOs discovered in "real world" program!
- Index(es):
Relevant Pages
|