diff options
author | Greg Hudson <ghudson@mit.edu> | 2012-10-20 16:52:29 -0400 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2012-12-19 12:15:46 -0500 |
commit | d9abacfd82b3336d133d12ed117173a1b6c0ba54 (patch) | |
tree | 6272f93d8f97ae2c3726a6854777fc4fa357c5ab /src/lib/krb5 | |
parent | 296c51d3208ddc37b64f5a0b06812e2705995c4b (diff) | |
download | krb5-d9abacfd82b3336d133d12ed117173a1b6c0ba54.tar.gz krb5-d9abacfd82b3336d133d12ed117173a1b6c0ba54.tar.xz krb5-d9abacfd82b3336d133d12ed117173a1b6c0ba54.zip |
Style cleanup for internal error handling
Fix style issues in kerrs.c and errors.c. Rename error handling
functions to use shorter k5_ prefix. Eliminate an inoperable
krb5int_set_error() call in gic_opte_alloc and convert the other
call to use krb5_set_error_message().
Diffstat (limited to 'src/lib/krb5')
-rw-r--r-- | src/lib/krb5/krb/gic_opt.c | 8 | ||||
-rw-r--r-- | src/lib/krb5/krb/kerrs.c | 67 | ||||
-rw-r--r-- | src/lib/krb5/krb5_libinit.c | 4 |
3 files changed, 41 insertions, 38 deletions
diff --git a/src/lib/krb5/krb/gic_opt.c b/src/lib/krb5/krb/gic_opt.c index 5b0fc83bb..7a8750d1f 100644 --- a/src/lib/krb5/krb/gic_opt.c +++ b/src/lib/krb5/krb/gic_opt.c @@ -176,8 +176,6 @@ gic_opte_alloc(krb5_context context) code = gic_opte_private_alloc(context, opte); if (code) { - krb5int_set_error(&context->err, code, - "gic_opte_alloc: gic_opte_private_alloc failed"); free(opte); return NULL; } @@ -287,9 +285,9 @@ krb5int_gic_opt_to_opte(krb5_context context, if (force) { return gic_opte_copy(context, opt, opte); } else { - krb5int_set_error(&context->err, EINVAL, - _("%s: attempt to convert non-extended " - "krb5_get_init_creds_opt"), where); + krb5_set_error_message(context, EINVAL, + _("%s: attempt to convert non-extended " + "krb5_get_init_creds_opt"), where); return EINVAL; } } diff --git a/src/lib/krb5/krb/kerrs.c b/src/lib/krb5/krb/kerrs.c index b94fd82b7..416cb7718 100644 --- a/src/lib/krb5/krb/kerrs.c +++ b/src/lib/krb5/krb/kerrs.c @@ -36,61 +36,66 @@ static int error_message_debug = 0; #undef krb5_set_error_message void KRB5_CALLCONV_C -krb5_set_error_message (krb5_context ctx, krb5_error_code code, - const char *fmt, ...) +krb5_set_error_message(krb5_context ctx, krb5_error_code code, + const char *fmt, ...) { va_list args; + if (ctx == NULL) return; - va_start (args, fmt); + va_start(args, fmt); #ifdef DEBUG - if (ERROR_MESSAGE_DEBUG()) + if (ERROR_MESSAGE_DEBUG()) { fprintf(stderr, "krb5_set_error_message(ctx=%p/err=%p, code=%ld, ...)\n", - ctx, &ctx->err, (long) code); + ctx, &ctx->err, (long)code); + } #endif - krb5int_vset_error (&ctx->err, code, fmt, args); + k5_vset_error(&ctx->err, code, fmt, args); #ifdef DEBUG if (ERROR_MESSAGE_DEBUG()) fprintf(stderr, "->%s\n", ctx->err.msg); #endif - va_end (args); + va_end(args); } void KRB5_CALLCONV_C -krb5_set_error_message_fl (krb5_context ctx, krb5_error_code code, - const char *file, int line, const char *fmt, ...) +krb5_set_error_message_fl(krb5_context ctx, krb5_error_code code, + const char *file, int line, const char *fmt, ...) { va_list args; + if (ctx == NULL) return; - va_start (args, fmt); + va_start(args, fmt); #ifdef DEBUG - if (ERROR_MESSAGE_DEBUG()) + if (ERROR_MESSAGE_DEBUG()) { fprintf(stderr, "krb5_set_error_message(ctx=%p/err=%p, code=%ld, ...)\n", - ctx, &ctx->err, (long) code); + ctx, &ctx->err, (long)code); + } #endif - krb5int_vset_error_fl (&ctx->err, code, file, line, fmt, args); + k5_vset_error_fl(&ctx->err, code, file, line, fmt, args); #ifdef DEBUG if (ERROR_MESSAGE_DEBUG()) fprintf(stderr, "->%s\n", ctx->err.msg); #endif - va_end (args); + va_end(args); } void KRB5_CALLCONV -krb5_vset_error_message (krb5_context ctx, krb5_error_code code, - const char *fmt, va_list args) +krb5_vset_error_message(krb5_context ctx, krb5_error_code code, + const char *fmt, va_list args) { #ifdef DEBUG - if (ERROR_MESSAGE_DEBUG()) + if (ERROR_MESSAGE_DEBUG()) { fprintf(stderr, "krb5_vset_error_message(ctx=%p, code=%ld, ...)\n", - ctx, (long) code); + ctx, (long)code); + } #endif if (ctx == NULL) return; - krb5int_vset_error (&ctx->err, code, fmt, args); + k5_vset_error(&ctx->err, code, fmt, args); #ifdef DEBUG if (ERROR_MESSAGE_DEBUG()) fprintf(stderr, "->%s\n", ctx->err.msg); @@ -99,32 +104,32 @@ krb5_vset_error_message (krb5_context ctx, krb5_error_code code, /* Set the error message state of dest_ctx to that of src_ctx. */ void KRB5_CALLCONV -krb5_copy_error_message (krb5_context dest_ctx, krb5_context src_ctx) +krb5_copy_error_message(krb5_context dest_ctx, krb5_context src_ctx) { if (dest_ctx == src_ctx) return; - if (src_ctx->err.msg) { - krb5int_set_error(&dest_ctx->err, src_ctx->err.code, "%s", - src_ctx->err.msg); + if (src_ctx->err.msg != NULL) { + k5_set_error(&dest_ctx->err, src_ctx->err.code, "%s", + src_ctx->err.msg); } else { - krb5int_clear_error(&dest_ctx->err); + k5_clear_error(&dest_ctx->err); } } const char * KRB5_CALLCONV -krb5_get_error_message (krb5_context ctx, krb5_error_code code) +krb5_get_error_message(krb5_context ctx, krb5_error_code code) { #ifdef DEBUG if (ERROR_MESSAGE_DEBUG()) - fprintf(stderr, "krb5_get_error_message(%p, %ld)\n", ctx, (long) code); + fprintf(stderr, "krb5_get_error_message(%p, %ld)\n", ctx, (long)code); #endif if (ctx == NULL) return error_message(code); - return krb5int_get_error (&ctx->err, code); + return k5_get_error(&ctx->err, code); } void KRB5_CALLCONV -krb5_free_error_message (krb5_context ctx, const char *msg) +krb5_free_error_message(krb5_context ctx, const char *msg) { #ifdef DEBUG if (ERROR_MESSAGE_DEBUG()) @@ -132,11 +137,11 @@ krb5_free_error_message (krb5_context ctx, const char *msg) #endif if (ctx == NULL) return; - krb5int_free_error (&ctx->err, msg); + k5_free_error(&ctx->err, msg); } void KRB5_CALLCONV -krb5_clear_error_message (krb5_context ctx) +krb5_clear_error_message(krb5_context ctx) { #ifdef DEBUG if (ERROR_MESSAGE_DEBUG()) @@ -144,5 +149,5 @@ krb5_clear_error_message (krb5_context ctx) #endif if (ctx == NULL) return; - krb5int_clear_error (&ctx->err); + k5_clear_error(&ctx->err); } diff --git a/src/lib/krb5/krb5_libinit.c b/src/lib/krb5/krb5_libinit.c index cb72d508a..f83d25b1c 100644 --- a/src/lib/krb5/krb5_libinit.c +++ b/src/lib/krb5/krb5_libinit.c @@ -28,7 +28,7 @@ int krb5int_lib_init(void) { int err; - krb5int_set_error_info_callout_fn (error_message); + k5_set_error_info_callout_fn(error_message); #ifdef SHOW_INITFINI_FUNCS printf("krb5int_lib_init\n"); @@ -103,7 +103,7 @@ void krb5int_lib_fini(void) remove_error_table(&et_asn1_error_table); remove_error_table(&et_k524_error_table); - krb5int_set_error_info_callout_fn (0); + k5_set_error_info_callout_fn(NULL); } /* Still exists because it went into the export list on Windows. But |