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 | |
parent | 296c51d3208ddc37b64f5a0b06812e2705995c4b (diff) | |
download | krb5-d9abacfd82b3336d133d12ed117173a1b6c0ba54.zip krb5-d9abacfd82b3336d133d12ed117173a1b6c0ba54.tar.gz krb5-d9abacfd82b3336d133d12ed117173a1b6c0ba54.tar.bz2 |
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().
-rw-r--r-- | src/include/k5-err.h | 42 | ||||
-rw-r--r-- | src/lib/crypto/krb/cf2.c | 7 | ||||
-rw-r--r-- | src/lib/gssapi/mechglue/g_initialize.c | 2 | ||||
-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 | ||||
-rw-r--r-- | src/util/profile/prof_init.c | 2 | ||||
-rw-r--r-- | src/util/support/errors.c | 128 | ||||
-rw-r--r-- | src/util/support/libkrb5support-fixed.exports | 16 | ||||
-rw-r--r-- | src/util/support/plugins.c | 16 |
10 files changed, 147 insertions, 145 deletions
diff --git a/src/include/k5-err.h b/src/include/k5-err.h index f9d5b0c..b677f19 100644 --- a/src/include/k5-err.h +++ b/src/include/k5-err.h @@ -48,49 +48,41 @@ struct errinfo { char scratch_buf[1024]; }; -void -krb5int_set_error (struct errinfo *ep, - long code, - const char *fmt, ...) +void k5_set_error(struct errinfo *ep, long code, const char *fmt, ...) #if !defined(__cplusplus) && (__GNUC__ > 2) __attribute__((__format__(__printf__, 3, 4))) #endif ; -void -krb5int_vset_error (struct errinfo *ep, long code, - const char *fmt, va_list args) + +void k5_vset_error(struct errinfo *ep, long code, const char *fmt, + va_list args) #if !defined(__cplusplus) && (__GNUC__ > 2) __attribute__((__format__(__printf__, 3, 0))) #endif ; -void -krb5int_set_error_fl (struct errinfo *ep, long code, - const char *file, int line, - const char *fmt, ...) + +void k5_set_error_fl(struct errinfo *ep, long code, const char *file, int line, + const char *fmt, ...) #if !defined(__cplusplus) && (__GNUC__ > 2) __attribute__((__format__(__printf__, 5, 6))) #endif ; -void -krb5int_vset_error_fl (struct errinfo *ep, long code, - const char *file, int line, - const char *fmt, va_list args) + +void k5_vset_error_fl(struct errinfo *ep, long code, const char *file, + int line, const char *fmt, va_list args) #if !defined(__cplusplus) && (__GNUC__ > 2) __attribute__((__format__(__printf__, 5, 0))) #endif ; -const char * -krb5int_get_error (struct errinfo *ep, long code); -void -krb5int_free_error (struct errinfo *ep, const char *msg); -void -krb5int_clear_error (struct errinfo *ep); -void -krb5int_set_error_info_callout_fn (const char *(KRB5_CALLCONV *f)(long)); + +const char *k5_get_error(struct errinfo *ep, long code); +void k5_free_error(struct errinfo *ep, const char *msg); +void k5_clear_error(struct errinfo *ep); +void k5_set_error_info_callout_fn(const char *(KRB5_CALLCONV *f)(long)); #ifdef DEBUG_ERROR_LOCATIONS -#define krb5int_set_error(ep, code, ...) \ - krb5int_set_error_fl(ep, code, __FILE__, __LINE__, __VA_ARGS__) +#define k5_set_error(ep, code, ...) \ + k5_set_error_fl(ep, code, __FILE__, __LINE__, __VA_ARGS__) #endif #endif /* K5_ERR_H */ diff --git a/src/lib/crypto/krb/cf2.c b/src/lib/crypto/krb/cf2.c index 7334ed1..1d0a01b 100644 --- a/src/lib/crypto/krb/cf2.c +++ b/src/lib/crypto/krb/cf2.c @@ -110,9 +110,10 @@ krb5_c_fx_cf2_simple(krb5_context context, 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, - _("Enctype %d has no PRF"), out_enctype_num); + if (context) { + k5_set_error(&(context->err), KRB5_CRYPTO_INTERNAL, + _("Enctype %d has no PRF"), out_enctype_num); + } return KRB5_CRYPTO_INTERNAL; } keybytes = out_enctype->enc->keybytes; diff --git a/src/lib/gssapi/mechglue/g_initialize.c b/src/lib/gssapi/mechglue/g_initialize.c index a7303b6..0d38105 100644 --- a/src/lib/gssapi/mechglue/g_initialize.c +++ b/src/lib/gssapi/mechglue/g_initialize.c @@ -891,7 +891,7 @@ cleanup: #endif if (dl != NULL) krb5int_close_plugin(dl); - krb5int_clear_error(&errinfo); + k5_clear_error(&errinfo); } static void diff --git a/src/lib/krb5/krb/gic_opt.c b/src/lib/krb5/krb/gic_opt.c index 5b0fc83..7a8750d 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 b94fd82..416cb77 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 cb72d50..f83d25b 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 diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c index 7dc5b47..5b2bb22 100644 --- a/src/util/profile/prof_init.c +++ b/src/util/profile/prof_init.c @@ -156,7 +156,7 @@ init_load_module(const char *modspec, profile_t *ret_profile) cleanup: free(modpath); free(residual); - krb5int_clear_error(&einfo); + k5_clear_error(&einfo); if (err) { if (have_cbdata && vtable.cleanup) vtable.cleanup(cbdata); diff --git a/src/util/support/errors.c b/src/util/support/errors.c index 5dba532..9b626c2 100644 --- a/src/util/support/errors.c +++ b/src/util/support/errors.c @@ -1,7 +1,9 @@ /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -/* Can't include krb5.h here, or k5-int.h which includes it, because - krb5.h needs to be generated with error tables, after util/et, - which builds after this directory. */ +/* + * Can't include krb5.h here, or k5-int.h which includes it, because krb5.h + * needs to be generated with error tables, after util/et, which builds after + * this directory. + */ #include <stdarg.h> #include <string.h> #include <stdlib.h> @@ -12,12 +14,16 @@ #include "k5-platform.h" #include "supp-int.h" -/* It would be nice to just use error_message() always. Pity that - it's defined in a library that depends on this one, and we're not - allowed to make circular dependencies. */ -/* We really want a rwlock here, since we should hold it while calling - the function and copying out its results. But I haven't - implemented shims for rwlock yet. */ +/* + * It would be nice to just use error_message() always. Pity that it's defined + * in a library that depends on this one, and we're not allowed to make + * circular dependencies. + */ +/* + * We really want a rwlock here, since we should hold it while calling the + * function and copying out its results. But I haven't implemented shims for + * rwlock yet. + */ static k5_mutex_t krb5int_error_info_support_mutex = K5_MUTEX_PARTIAL_INITIALIZER; static const char *(KRB5_CALLCONV *fptr)(long); /* = &error_message */ @@ -25,55 +31,54 @@ static const char *(KRB5_CALLCONV *fptr)(long); /* = &error_message */ int krb5int_err_init (void) { - return k5_mutex_finish_init (&krb5int_error_info_support_mutex); + return k5_mutex_finish_init(&krb5int_error_info_support_mutex); } #define initialize() krb5int_call_thread_support_init() #define lock() k5_mutex_lock(&krb5int_error_info_support_mutex) #define unlock() k5_mutex_unlock(&krb5int_error_info_support_mutex) -#undef krb5int_set_error +#undef k5_set_error void -krb5int_set_error (struct errinfo *ep, long code, const char *fmt, ...) +k5_set_error(struct errinfo *ep, long code, const char *fmt, ...) { va_list args; - va_start (args, fmt); - krb5int_vset_error_fl (ep, code, NULL, 0, fmt, args); - va_end (args); + + va_start(args, fmt); + k5_vset_error_fl(ep, code, NULL, 0, fmt, args); + va_end(args); } void -krb5int_set_error_fl (struct errinfo *ep, long code, - const char *file, int line, const char *fmt, ...) +k5_set_error_fl(struct errinfo *ep, long code, const char *file, int line, + const char *fmt, ...) { va_list args; - va_start (args, fmt); - krb5int_vset_error_fl (ep, code, file, line, fmt, args); - va_end (args); + + va_start(args, fmt); + k5_vset_error_fl(ep, code, file, line, fmt, args); + va_end(args); } void -krb5int_vset_error (struct errinfo *ep, long code, - const char *fmt, va_list args) +k5_vset_error(struct errinfo *ep, long code, const char *fmt, va_list args) { - krb5int_vset_error_fl(ep, code, NULL, 0, fmt, args); + k5_vset_error_fl(ep, code, NULL, 0, fmt, args); } void -krb5int_vset_error_fl (struct errinfo *ep, long code, - const char *file, int line, - const char *fmt, va_list args) +k5_vset_error_fl(struct errinfo *ep, long code, const char *file, int line, + const char *fmt, va_list args) { va_list args2; char *str = NULL, *str2, *slash; - /* try vasprintf first */ + /* Try vasprintf first. */ va_copy(args2, args); - if (vasprintf(&str, fmt, args2) < 0) { + if (vasprintf(&str, fmt, args2) < 0) str = NULL; - } va_end(args2); - if (str && line) { + if (str != NULL && line) { /* Try to add file and line suffix. */ slash = strrchr(file, '/'); if (slash) @@ -84,26 +89,25 @@ krb5int_vset_error_fl (struct errinfo *ep, long code, } } - /* If that failed, try using scratch_buf */ + /* If vasprintf failed, try using scratch_buf. */ if (str == NULL) { vsnprintf(ep->scratch_buf, sizeof(ep->scratch_buf), fmt, args); str = strdup(ep->scratch_buf); /* try allocating again */ } - /* free old string before setting new one */ - if (ep->msg && ep->msg != ep->scratch_buf) { - krb5int_free_error (ep, ep->msg); - ep->msg = NULL; - } + /* Free old string before setting new one. */ + k5_clear_error(ep); ep->code = code; - ep->msg = str ? str : ep->scratch_buf; + ep->msg = (str != NULL) ? str : ep->scratch_buf; } const char * -krb5int_get_error (struct errinfo *ep, long code) +k5_get_error(struct errinfo *ep, long code) { const char *r, *r2; - if (code == ep->code && ep->msg) { + char *p; + + if (code == ep->code && ep->msg != NULL) { r = strdup(ep->msg); if (r == NULL) { strlcpy(ep->scratch_buf, _("Out of memory"), @@ -124,36 +128,38 @@ krb5int_get_error (struct errinfo *ep, long code) if (fptr == NULL) { unlock(); no_fptr: - /* Theoretically, according to ISO C, strerror should be able - to give us a message back for any int value. However, on - UNIX at least, the errno codes strerror will actually be - useful for are positive, so a negative value here would be - kind of weird. - - Coverity Prevent thinks we shouldn't be passing negative - values to strerror, and it's not likely to be useful, so - let's not do it. - - Besides, normally we shouldn't get here; fptr should take - us to a callback function in the com_err library. */ + /* + * Theoretically, according to ISO C, strerror should be able + * to give us a message back for any int value. However, on + * UNIX at least, the errno codes strerror will actually be + * useful for are positive, so a negative value here would be + * kind of weird. + * + * Coverity Prevent thinks we shouldn't be passing negative + * values to strerror, and it's not likely to be useful, so + * let's not do it. + * + * Besides, normally we shouldn't get here; fptr should take + * us to a callback function in the com_err library. + */ if (code < 0) goto format_number; #ifdef HAVE_STRERROR_R if (strerror_r(code, ep->scratch_buf, sizeof(ep->scratch_buf)) == 0) { - char *p = strdup(ep->scratch_buf); - if (p) + p = strdup(ep->scratch_buf); + if (p != NULL) return p; return ep->scratch_buf; } #endif r = strerror(code); - if (r) { + if (r != NULL) { strlcpy(ep->scratch_buf, r, sizeof(ep->scratch_buf)); return ep->scratch_buf; } format_number: - snprintf (ep->scratch_buf, sizeof(ep->scratch_buf), - _("error %ld"), code); + snprintf(ep->scratch_buf, sizeof(ep->scratch_buf), _("error %ld"), + code); return ep->scratch_buf; } r = fptr(code); @@ -178,21 +184,21 @@ krb5int_get_error (struct errinfo *ep, long code) } void -krb5int_free_error (struct errinfo *ep, const char *msg) +k5_free_error(struct errinfo *ep, const char *msg) { if (msg != ep->scratch_buf) - free ((char *) msg); + free((char *)msg); } void -krb5int_clear_error (struct errinfo *ep) +k5_clear_error(struct errinfo *ep) { - krb5int_free_error (ep, ep->msg); + k5_free_error(ep, ep->msg); ep->msg = NULL; } void -krb5int_set_error_info_callout_fn (const char *(KRB5_CALLCONV *f)(long)) +k5_set_error_info_callout_fn(const char *(KRB5_CALLCONV *f)(long)) { initialize(); if (lock() == 0) { diff --git a/src/util/support/libkrb5support-fixed.exports b/src/util/support/libkrb5support-fixed.exports index 0579611..c813310 100644 --- a/src/util/support/libkrb5support-fixed.exports +++ b/src/util/support/libkrb5support-fixed.exports @@ -1,3 +1,11 @@ +k5_set_error +k5_vset_error +k5_set_error_fl +k5_vset_error_fl +k5_get_error +k5_free_error +k5_clear_error +k5_set_error_info_callout_fn k5_json_array_add k5_json_array_create k5_json_array_get @@ -50,14 +58,6 @@ krb5int_mutex_alloc krb5int_mutex_free krb5int_mutex_lock krb5int_mutex_unlock -krb5int_set_error -krb5int_vset_error -krb5int_set_error_fl -krb5int_vset_error_fl -krb5int_get_error -krb5int_free_error -krb5int_clear_error -krb5int_set_error_info_callout_fn krb5int_gmt_mktime krb5int_buf_init_fixed krb5int_buf_init_dynamic diff --git a/src/util/support/plugins.c b/src/util/support/plugins.c index 02e37ee..608d03c 100644 --- a/src/util/support/plugins.c +++ b/src/util/support/plugins.c @@ -174,8 +174,8 @@ krb5int_open_plugin (const char *filepath, struct plugin_file_handle **h, struct if (stat (filepath, &statbuf) < 0) { err = errno; Tprintf ("stat(%s): %s\n", filepath, strerror (err)); - krb5int_set_error(ep, err, _("unable to find plugin [%s]: %s"), - filepath, strerror(err)); + k5_set_error(ep, err, _("unable to find plugin [%s]: %s"), + filepath, strerror(err)); } } @@ -270,8 +270,8 @@ krb5int_open_plugin (const char *filepath, struct plugin_file_handle **h, struct e = _("unknown failure"); Tprintf ("dlopen(%s): %s\n", filepath, e); err = ENOENT; /* XXX */ - krb5int_set_error(ep, err, _("unable to load plugin [%s]: %s"), - filepath, e); + k5_set_error(ep, err, _("unable to load plugin [%s]: %s"), + filepath, e); } } @@ -293,7 +293,7 @@ krb5int_open_plugin (const char *filepath, struct plugin_file_handle **h, struct if (handle == NULL) { Tprintf ("Unable to load dll: %s\n", filepath); err = ENOENT; /* XXX */ - krb5int_set_error(ep, err, _("unable to load DLL [%s]"), filepath); + k5_set_error(ep, err, _("unable to load DLL [%s]"), filepath); } if (!err) { @@ -309,7 +309,7 @@ krb5int_open_plugin (const char *filepath, struct plugin_file_handle **h, struct if (!err && !got_plugin) { err = ENOENT; /* no plugin or no way to load plugins */ - krb5int_set_error(ep, err, _("plugin unavailable: %s"), strerror(err)); + k5_set_error(ep, err, _("plugin unavailable: %s"), strerror(err)); } if (!err) { @@ -341,7 +341,7 @@ krb5int_get_plugin_sym (struct plugin_file_handle *h, e = "unknown failure"; Tprintf ("dlsym(%s): %s\n", csymname, e); err = ENOENT; /* XXX */ - krb5int_set_error(ep, err, "%s", e); + k5_set_error(ep, err, "%s", e); } } #endif @@ -356,7 +356,7 @@ krb5int_get_plugin_sym (struct plugin_file_handle *h, const char *e = "unable to get dll symbol"; /* XXX copy and save away */ Tprintf ("GetProcAddress(%s): %i\n", csymname, GetLastError()); err = ENOENT; /* XXX */ - krb5int_set_error(ep, err, "%s", e); + k5_set_error(ep, err, "%s", e); dw = GetLastError(); if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | |