[26424] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

svn rev #25760: trunk/src/ lib/apputils/ lib/crypto/krb/ util/et/

daemon@ATHENA.MIT.EDU (ghudson@mit.edu)
Fri Mar 9 13:30:33 2012

Date: Fri, 9 Mar 2012 13:30:31 -0500
From: ghudson@mit.edu
Message-Id: <201203091830.q29IUV5Q003597@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

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);

_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post