From: Florian Forster Date: Wed, 28 Sep 2016 19:27:54 +0000 (+0200) Subject: src/daemon/plugin.[ch]: Make the user_data_t* const. X-Git-Tag: collectd-5.6.1~3 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=69d058a6ce8557e24b604b8efb09136e02054bd0;p=collectd.git src/daemon/plugin.[ch]: Make the user_data_t* const. That is, user_data_t* passed to register_* functions. The actual callbacks are still getting a user_data_t* since they, in theory, would be able to modify the pointer stored in .data. Issue: #1954 --- diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c index d6cf877a..1fbd77df 100644 --- a/src/daemon/plugin.c +++ b/src/daemon/plugin.c @@ -365,7 +365,7 @@ static void log_list_callbacks (llist_t **list, /* {{{ */ } /* }}} void log_list_callbacks */ static int create_register_callback (llist_t **list, /* {{{ */ - const char *name, void *callback, user_data_t *ud) + const char *name, void *callback, user_data_t const *ud) { callback_func_t *cf; @@ -1266,7 +1266,7 @@ int plugin_register_read (const char *name, int plugin_register_complex_read (const char *group, const char *name, plugin_read_cb callback, cdtime_t interval, - user_data_t *user_data) + user_data_t const *user_data) { read_func_t *rf; int status; @@ -1310,7 +1310,7 @@ int plugin_register_complex_read (const char *group, const char *name, } /* int plugin_register_complex_read */ int plugin_register_write (const char *name, - plugin_write_cb callback, user_data_t *ud) + plugin_write_cb callback, user_data_t const *ud) { return (create_register_callback (&list_write, name, (void *) callback, ud)); @@ -1357,7 +1357,7 @@ static char *plugin_flush_callback_name (const char *name) } /* static char *plugin_flush_callback_name */ int plugin_register_flush (const char *name, - plugin_flush_cb callback, user_data_t *ud) + plugin_flush_cb callback, user_data_t const *ud) { int status; plugin_ctx_t ctx = plugin_get_ctx (); @@ -1417,7 +1417,7 @@ int plugin_register_flush (const char *name, } /* int plugin_register_flush */ int plugin_register_missing (const char *name, - plugin_missing_cb callback, user_data_t *ud) + plugin_missing_cb callback, user_data_t const *ud) { return (create_register_callback (&list_missing, name, (void *) callback, ud)); @@ -1488,14 +1488,14 @@ int plugin_register_data_set (const data_set_t *ds) } /* int plugin_register_data_set */ int plugin_register_log (const char *name, - plugin_log_cb callback, user_data_t *ud) + plugin_log_cb callback, user_data_t const *ud) { return (create_register_callback (&list_log, name, (void *) callback, ud)); } /* int plugin_register_log */ int plugin_register_notification (const char *name, - plugin_notification_cb callback, user_data_t *ud) + plugin_notification_cb callback, user_data_t const *ud) { return (create_register_callback (&list_notification, name, (void *) callback, ud)); diff --git a/src/daemon/plugin.h b/src/daemon/plugin.h index de42c068..d3038a39 100644 --- a/src/daemon/plugin.h +++ b/src/daemon/plugin.h @@ -296,20 +296,20 @@ int plugin_register_read (const char *name, int plugin_register_complex_read (const char *group, const char *name, plugin_read_cb callback, cdtime_t interval, - user_data_t *user_data); + user_data_t const *user_data); int plugin_register_write (const char *name, - plugin_write_cb callback, user_data_t *user_data); + plugin_write_cb callback, user_data_t const *user_data); int plugin_register_flush (const char *name, - plugin_flush_cb callback, user_data_t *user_data); + plugin_flush_cb callback, user_data_t const *user_data); int plugin_register_missing (const char *name, - plugin_missing_cb callback, user_data_t *user_data); + plugin_missing_cb callback, user_data_t const *user_data); int plugin_register_shutdown (const char *name, plugin_shutdown_cb callback); int plugin_register_data_set (const data_set_t *ds); int plugin_register_log (const char *name, - plugin_log_cb callback, user_data_t *user_data); + plugin_log_cb callback, user_data_t const *user_data); int plugin_register_notification (const char *name, - plugin_notification_cb callback, user_data_t *user_data); + plugin_notification_cb callback, user_data_t const *user_data); int plugin_unregister_config (const char *name); int plugin_unregister_complex_config (const char *name);