From 8836e6a39d6c6e3e77d780ac6c9789e65a7f8649 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 20 Jan 2022 09:09:27 -0500 Subject: [PATCH] lib/krb5: krb5_vset_error_message is no-op if no krb5_context Refactor krb5_vset_error_message() to remove the many conditional tests on the existence of krb5_context. If there is no krb5_context then _krb5_debug() is a no-op. Therefore, there is no point in performing any of the other work. Change-Id: Ib88b592a542a195f27e352a80ced0a98a6f85300 --- lib/krb5/error_string.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/krb5/error_string.c b/lib/krb5/error_string.c index ed82c6cdc..da86b375f 100644 --- a/lib/krb5/error_string.c +++ b/lib/krb5/error_string.c @@ -95,17 +95,16 @@ krb5_vset_error_message(krb5_context context, krb5_error_code ret, const char *fmt, va_list args) __attribute__ ((__format__ (__printf__, 3, 0))) { - if (context) { - const char *msg; + const char *msg; - heim_vset_error_message(context ? context->hcontext : NULL, ret, fmt, - args); - msg = heim_get_error_message(context ? context->hcontext : NULL, ret); - if (msg) { - if (context) - _krb5_debug(context, 100, "error message: %s: %d", msg, ret); - heim_free_error_message(context ? context->hcontext : NULL, msg); - } + if (context == NULL) + return; + + heim_vset_error_message(context->hcontext, ret, fmt, args); + msg = heim_get_error_message(context->hcontext, ret); + if (msg) { + _krb5_debug(context, 100, "error message: %s: %d", msg, ret); + heim_free_error_message(context->hcontext, msg); } }