svn rev #25760: trunk/src/ lib/apputils/ lib/crypto/krb/ util/et/
ghudson@MIT.EDU
ghudson at MIT.EDU
Fri Mar 9 13:30:31 EST 2012
http://src.mit.edu/fisheye/changelog/krb5/?cs=25760
Commit By: ghudson
Log Message:
ticket: 7105
Avoid side effects in assert expressions
asserts may be compiled out with -DNDEBUG, so it's wrong to use an
assert expression with an important side effect.
(We also have scores of side-effecting asserts in test programs, but
those are less important and can be dealt with separately.)
Changed Files:
U trunk/src/lib/apputils/net-server.c
U trunk/src/lib/crypto/krb/cf2.c
U trunk/src/util/et/com_err.c
Modified: trunk/src/lib/apputils/net-server.c
===================================================================
--- trunk/src/lib/apputils/net-server.c 2012-03-08 22:38:58 UTC (rev 25759)
+++ trunk/src/lib/apputils/net-server.c 2012-03-09 18:30:31 UTC (rev 25760)
@@ -1066,7 +1066,10 @@
do_network_reconfig(verto_ctx *ctx, verto_ev *ev)
{
struct connection *conn = verto_get_private(ev);
- assert(loop_setup_network(ctx, conn->handle, conn->prog) == 0);
+ if (loop_setup_network(ctx, conn->handle, conn->prog) != 0) {
+ krb5_klog_syslog(LOG_ERR, _("Failed to reconfigure network, exiting"));
+ verto_break(ctx);
+ }
}
static int
Modified: trunk/src/lib/crypto/krb/cf2.c
===================================================================
--- trunk/src/lib/crypto/krb/cf2.c 2012-03-08 22:38:58 UTC (rev 25759)
+++ trunk/src/lib/crypto/krb/cf2.c 2012-03-09 18:30:31 UTC (rev 25760)
@@ -107,7 +107,8 @@
return KRB5_BAD_ENCTYPE;
out_enctype_num = k1->enctype;
assert(out != NULL);
- assert((out_enctype = find_enctype(out_enctype_num)) != NULL);
+ out_enctype = find_enctype(out_enctype_num);
+ assert(out_enctype != NULL);
if (out_enctype->prf == NULL) {
if (context)
krb5int_set_error(&(context->err), KRB5_CRYPTO_INTERNAL,
Modified: trunk/src/util/et/com_err.c
===================================================================
--- trunk/src/util/et/com_err.c 2012-03-08 22:38:58 UTC (rev 25759)
+++ trunk/src/util/et/com_err.c 2012-03-09 18:30:31 UTC (rev 25760)
@@ -154,8 +154,10 @@
et_old_error_hook_func x;
/* Broken initialization? What can we do? */
- assert(com_err_finish_init() == 0);
- assert(com_err_lock_hook_handle() == 0);
+ if (com_err_finish_init() != 0)
+ abort();
+ if (com_err_lock_hook_handle() != 0)
+ abort();
x = com_err_hook;
com_err_hook = new_proc;
k5_mutex_unlock(&com_err_hook_lock);
@@ -167,8 +169,10 @@
et_old_error_hook_func x;
/* Broken initialization? What can we do? */
- assert(com_err_finish_init() == 0);
- assert(com_err_lock_hook_handle() == 0);
+ if (com_err_finish_init() != 0)
+ abort();
+ if (com_err_lock_hook_handle() != 0)
+ abort();
x = com_err_hook;
com_err_hook = NULL;
k5_mutex_unlock(&com_err_hook_lock);
More information about the cvs-krb5
mailing list