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
This commit is contained in:
Jeffrey Altman
2022-01-20 09:09:27 -05:00
parent e32f7a4387
commit 8836e6a39d

View File

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