From 434b34d71c39820b4e2415dca646a39bee1086fb Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 7 Feb 2019 23:04:16 -0500 Subject: [PATCH] lib/krb5: prevent build failures of krb5_plugin_common on Windows The Microsoft compiler cannot handle multiple const modifiers for the same type. It is also unhappy with the output pointer parameter being declared const. This change introduces new typedefs and cast of the dlsym() return type to prevent warnings. Change-Id: Ia92645efab8d2ec6745339a6f47c690782ae730a --- lib/krb5/ccache_plugin.h | 2 +- lib/krb5/common_plugin.h | 7 +++++-- lib/krb5/plugin.c | 14 +++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/krb5/ccache_plugin.h b/lib/krb5/ccache_plugin.h index 4539fc9a1..11e8f61f9 100644 --- a/lib/krb5/ccache_plugin.h +++ b/lib/krb5/ccache_plugin.h @@ -41,6 +41,6 @@ krb5_error_code KRB5_CALLCONV ccache_ops_plugin_load(krb5_context context, krb5_get_instance_func_t *func, size_t *n_ftables, - const krb5_plugin_common_ftable *const **ftables); + krb5_plugin_common_ftable_p **ftables); #endif /* HEIMDAL_KRB5_CCACHE_PLUGIN_H */ diff --git a/lib/krb5/common_plugin.h b/lib/krb5/common_plugin.h index 812c4a155..6b92eb81c 100644 --- a/lib/krb5/common_plugin.h +++ b/lib/krb5/common_plugin.h @@ -39,11 +39,14 @@ /* * All plugin function tables extend the following structure. */ -typedef struct krb5_plugin_common_ftable_desc { +struct krb5_plugin_common_ftable_desc { int version; krb5_error_code (KRB5_LIB_CALL *init)(krb5_context, void **); void (KRB5_LIB_CALL *fini)(void *); -} krb5_plugin_common_ftable; +}; +typedef struct krb5_plugin_common_ftable_desc krb5_plugin_common_ftable; +typedef struct krb5_plugin_common_ftable_desc *krb5_plugin_common_ftable_p; +typedef struct krb5_plugin_common_ftable_desc * const krb5_plugin_common_ftable_cp; /* * All plugins must export a function named "_plugin_load" with diff --git a/lib/krb5/plugin.c b/lib/krb5/plugin.c index f87d4ba07..e5e8f2858 100644 --- a/lib/krb5/plugin.c +++ b/lib/krb5/plugin.c @@ -151,7 +151,7 @@ copy_internal_dso(const char *name) } struct krb5_plugin { - krb5_plugin_common_ftable *ftable; + krb5_plugin_common_ftable_p ftable; void *ctx; }; @@ -482,7 +482,7 @@ add_dso_plugin_struct(krb5_context context, const char *name) { krb5_error_code ret; - krb5_plugin_common_ftable *cpm; + krb5_plugin_common_ftable_p cpm; struct krb5_plugin *pl; heim_array_t plugins; @@ -490,7 +490,7 @@ add_dso_plugin_struct(krb5_context context, return NULL; /* suppress error here because we may be looking for a different plugin type */ - cpm = dlsym(dsohandle, name); + cpm = (krb5_plugin_common_ftable_p)dlsym(dsohandle, name); if (cpm == NULL) return NULL; @@ -518,7 +518,7 @@ typedef krb5_error_code (KRB5_CALLCONV *krb5_plugin_load_t)(krb5_context context, krb5_get_instance_func_t *func, size_t *n_ftables, - const krb5_plugin_common_ftable *const **ftables); + krb5_plugin_common_ftable_cp **ftables); static krb5_boolean validate_plugin_deps(krb5_context context, @@ -575,13 +575,13 @@ add_dso_plugins_load_fn(krb5_context context, size_t i; krb5_get_instance_func_t get_instance; size_t n_ftables; - const krb5_plugin_common_ftable *const *ftables; + krb5_plugin_common_ftable_cp *ftables; if (asprintf(&sym, "%s_plugin_load", caller->name) == -1) return NULL; /* suppress error here because we may be looking for a different plugin type */ - load_fn = dlsym(dsohandle, sym); + load_fn = (krb5_plugin_load_t)dlsym(dsohandle, sym); free(sym); if (load_fn == NULL) return NULL; @@ -601,7 +601,7 @@ add_dso_plugins_load_fn(krb5_context context, plugins = heim_array_create(); for (i = 0; i < n_ftables; i++) { - const krb5_plugin_common_ftable *const cpm = ftables[i]; + krb5_plugin_common_ftable_cp cpm = ftables[i]; struct krb5_plugin *pl; pl = heim_alloc(sizeof(*pl), "krb5-plugin", plugin_free);