From eb0d98ba340ec1ba0b21ef169e9723f836c6f93f Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sun, 28 May 2023 21:00:15 +0000 Subject: [PATCH] base/plugin.c: Constify. As a bonus, eliminate an unnecessary rk_UNCONST. --- lib/base/common_plugin.h | 1 + lib/base/heimbase.h | 2 +- lib/base/plugin.c | 16 ++++++++-------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/base/common_plugin.h b/lib/base/common_plugin.h index ece1d2817..d7b6bcae4 100644 --- a/lib/base/common_plugin.h +++ b/lib/base/common_plugin.h @@ -75,6 +75,7 @@ struct heim_plugin_common_ftable_desc { }; typedef struct heim_plugin_common_ftable_desc heim_plugin_common_ftable; typedef struct heim_plugin_common_ftable_desc *heim_plugin_common_ftable_p; +typedef const struct heim_plugin_common_ftable_desc *heim_plugin_common_ftable_const_p; typedef struct heim_plugin_common_ftable_desc * const heim_plugin_common_ftable_cp; typedef int diff --git a/lib/base/heimbase.h b/lib/base/heimbase.h index d2c011414..4546df946 100644 --- a/lib/base/heimbase.h +++ b/lib/base/heimbase.h @@ -102,7 +102,7 @@ struct heim_plugin_data { const char *module; const char *name; int min_version; - const char **deps; + const char *const *deps; heim_get_instance_func_t get_instance; }; diff --git a/lib/base/plugin.c b/lib/base/plugin.c index 355306dd9..87bb5f7ac 100644 --- a/lib/base/plugin.c +++ b/lib/base/plugin.c @@ -152,7 +152,7 @@ copy_internal_dso(const char *name) } struct heim_plugin { - heim_plugin_common_ftable_p ftable; + heim_plugin_common_ftable_const_p ftable; void *ctx; }; @@ -166,7 +166,7 @@ plugin_free(void *ptr) } struct heim_plugin_register_ctx { - void *symbol; + const void *symbol; int is_dup; }; @@ -199,7 +199,7 @@ heim_plugin_register(heim_context context, heim_pcontext pcontext, const char *module, const char *name, - void *ftable) + const void *ftable) { heim_error_code ret; heim_array_t plugins; @@ -480,7 +480,7 @@ struct iter_ctx { heim_context context; heim_pcontext pcontext; heim_string_t n; - struct heim_plugin_data *caller; + const struct heim_plugin_data *caller; int flags; heim_array_t result; int32_t (HEIM_LIB_CALL *func)(void *, const void *, void *, void *); @@ -540,7 +540,7 @@ add_dso_plugin_struct(heim_context context, static int validate_plugin_deps(heim_context context, - struct heim_plugin_data *caller, + const struct heim_plugin_data *caller, const char *dsopath, heim_get_instance_func_t get_instance) { @@ -583,7 +583,7 @@ validate_plugin_deps(heim_context context, static heim_array_t add_dso_plugins_load_fn(heim_context context, heim_pcontext pcontext, - struct heim_plugin_data *caller, + const struct heim_plugin_data *caller, const char *dsopath, void *dsohandle) { @@ -635,7 +635,7 @@ add_dso_plugins_load_fn(heim_context context, heim_warn(context, ret, "plugin %s[%zu] failed to initialize", dsopath, i); } else { - pl->ftable = rk_UNCONST(cpm); + pl->ftable = cpm; heim_array_append_value(plugins, pl); } heim_release(pl); @@ -738,7 +738,7 @@ eval_results(heim_object_t value, void *ctx, int *stop) heim_error_code heim_plugin_run_f(heim_context context, heim_pcontext pcontext, - struct heim_plugin_data *caller, + const struct heim_plugin_data *caller, int flags, int32_t nohandle, void *userctx,