diff options
author | Greg Hudson <ghudson@mit.edu> | 2012-03-09 18:30:31 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2012-03-09 18:30:31 +0000 |
commit | 221cd4a23691601a14500bc00146c265b50bdc94 (patch) | |
tree | e54d818ccf2abb3956881ffb6281f75bb48122eb /src/util/et | |
parent | 0e5252ec1778d3421122f2ee95c88e8b1b77e383 (diff) | |
download | krb5-221cd4a23691601a14500bc00146c265b50bdc94.tar.gz krb5-221cd4a23691601a14500bc00146c265b50bdc94.tar.xz krb5-221cd4a23691601a14500bc00146c265b50bdc94.zip |
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.)
ticket: 7105
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25760 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/et')
-rw-r--r-- | src/util/et/com_err.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/util/et/com_err.c b/src/util/et/com_err.c index aaba89744f..96922ec24f 100644 --- a/src/util/et/com_err.c +++ b/src/util/et/com_err.c @@ -154,8 +154,10 @@ et_old_error_hook_func set_com_err_hook (et_old_error_hook_func new_proc) 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 reset_com_err_hook () 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); |