From: Russell Bryant rbryant@redhat.com
Remove unnecessary extern from a bunch of function prototypes. Tweak formatting of function prototypes to match coding guidelines.
Signed-off-by: Russell Bryant rbryant@redhat.com --- src/include/matahari/agent.h | 32 ++++++++------ src/include/matahari/host.h | 66 ++++++++++++++++++++-------- src/include/matahari/logging.h | 12 ++++- src/include/matahari/mainloop.h | 51 ++++++++++++---------- src/include/matahari/network.h | 23 ++++++---- src/include/matahari/services.h | 43 ++++++++++++------- src/include/matahari/sysconfig.h | 10 ++-- src/include/matahari/sysconfig_internal.h | 2 +- src/include/matahari/utilities.h | 31 +++++++++---- src/lib/host_private.h | 26 +++++++---- src/lib/network_private.h | 12 ++++- src/lib/services_private.h | 50 ++++++++++++++++++---- src/lib/sysconfig_private.h | 12 +++-- src/tests/mh_test_utilities.h | 3 +- 14 files changed, 248 insertions(+), 125 deletions(-)
diff --git a/src/include/matahari/agent.h b/src/include/matahari/agent.h index 8345841..4175809 100644 --- a/src/include/matahari/agent.h +++ b/src/include/matahari/agent.h @@ -74,25 +74,31 @@ typedef struct mainloop_qmf_s { * retval[1] failed to daemonize * retval[0] successfully daemonize */ -extern int +int mh_should_daemonize(int code, const char *name, const char *arg, void *userdata);
-extern int mh_add_option( - int code, int has_arg, const char *name, const char *description, - void *userdata, int(*callback)(int code, const char *name, const char *arg, void *userdata)); +int +mh_add_option(int code, int has_arg, const char *name, const char *description, + void *userdata, int(*callback)(int code, const char *name, + const char *arg, void *userdata));
-extern qpid::types::Variant::Map mh_parse_options( - const char *proc_name, int argc, char **argv, qpid::types::Variant::Map &options); +qpid::types::Variant::Map +mh_parse_options(const char *proc_name, int argc, char **argv, + qpid::types::Variant::Map &options);
-extern qpid::messaging::Connection mh_connect( - qpid::types::Variant::Map mh_options, qpid::types::Variant::Map amqp_options, int retry); +qpid::messaging::Connection +mh_connect(qpid::types::Variant::Map mh_options, + qpid::types::Variant::Map amqp_options, int retry);
-extern mainloop_qmf_t *mainloop_add_qmf(int priority, qmf::AgentSession session, - gboolean (*dispatch)(qmf::AgentSession session, qmf::AgentEvent event, - gpointer userdata), - GDestroyNotify notify, gpointer userdata); +mainloop_qmf_t * +mainloop_add_qmf(int priority, qmf::AgentSession session, + gboolean (*dispatch)(qmf::AgentSession session, + qmf::AgentEvent event, + gpointer userdata), + GDestroyNotify notify, gpointer userdata);
-extern gboolean mainloop_destroy_qmf(mainloop_qmf_t *source); +gboolean +mainloop_destroy_qmf(mainloop_qmf_t *source);
struct MatahariAgentImpl;
diff --git a/src/include/matahari/host.h b/src/include/matahari/host.h index ba540f7..1da756a 100644 --- a/src/include/matahari/host.h +++ b/src/include/matahari/host.h @@ -43,7 +43,7 @@ * * \return the UUID */ -extern const char * +const char * mh_host_get_uuid(const char *lifetime);
/** @@ -56,24 +56,44 @@ mh_host_get_uuid(const char *lifetime); * \retval 0 success * \retval non-zero failure */ -extern int +int mh_host_set_uuid(const char *lifetime, const char *uuid);
-extern const char *mh_host_get_hostname(void); -extern const char *mh_host_get_operating_system(void); +const char * +mh_host_get_hostname(void);
-extern const char *mh_host_get_architecture(void); -extern const char *mh_host_get_cpu_model(void); -extern const char *mh_host_get_cpu_flags(void); +const char * +mh_host_get_operating_system(void);
-extern uint64_t mh_host_get_memory(void); -extern uint64_t mh_host_get_mem_free(void); -extern uint64_t mh_host_get_swap(void); -extern uint64_t mh_host_get_swap_free(void); +const char * +mh_host_get_architecture(void);
-extern int mh_host_get_cpu_count(void); -extern int mh_host_get_cpu_number_of_cores(void); -extern int mh_host_get_cpu_wordsize(void); +const char * +mh_host_get_cpu_model(void); + +const char * +mh_host_get_cpu_flags(void); + +uint64_t +mh_host_get_memory(void); + +uint64_t +mh_host_get_mem_free(void); + +uint64_t +mh_host_get_swap(void); + +uint64_t +mh_host_get_swap_free(void); + +int +mh_host_get_cpu_count(void); + +int +mh_host_get_cpu_number_of_cores(void); + +int +mh_host_get_cpu_wordsize(void);
/** * Identify a host. @@ -83,11 +103,19 @@ extern int mh_host_get_cpu_wordsize(void); * \retval 0 success * \retval non-zero failure */ -extern int mh_host_identify(void); +int +mh_host_identify(void); + +void +mh_host_reboot(void); + +void +mh_host_shutdown(void); + +void +mh_host_get_load_averages(sigar_loadavg_t *avg);
-extern void mh_host_reboot(void); -extern void mh_host_shutdown(void); -extern void mh_host_get_load_averages(sigar_loadavg_t *avg); -extern void mh_host_get_processes(sigar_proc_stat_t *procs); +void +mh_host_get_processes(sigar_proc_stat_t *procs);
#endif // __MH_HOST_H__ diff --git a/src/include/matahari/logging.h b/src/include/matahari/logging.h index 7d152a9..260eccc 100644 --- a/src/include/matahari/logging.h +++ b/src/include/matahari/logging.h @@ -46,9 +46,15 @@ #define LOG_TRACE 8
extern int mh_log_level; -extern void mh_log_fn(int priority, const char * fmt, ...) G_GNUC_PRINTF(2,3); -extern void mh_log_init(const char *ident, int level, gboolean to_stderr); -extern void mh_enable_stderr(gboolean to_stderr); + +void +mh_log_fn(int priority, const char * fmt, ...) G_GNUC_PRINTF(2,3); + +void +mh_log_init(const char *ident, int level, gboolean to_stderr); + +void +mh_enable_stderr(gboolean to_stderr);
#if SUPPORT_TRACING
diff --git a/src/include/matahari/mainloop.h b/src/include/matahari/mainloop.h index 43a7a20..74adce8 100644 --- a/src/include/matahari/mainloop.h +++ b/src/include/matahari/mainloop.h @@ -28,48 +28,52 @@ #include <glib.h> #include <sys/types.h>
-extern gboolean mainloop_signal(int sig, void (*dispatch)(int sig)); +gboolean +mainloop_signal(int sig, void (*dispatch)(int sig));
-extern gboolean mainloop_add_signal(int sig, void (*dispatch)(int sig)); +gboolean +mainloop_add_signal(int sig, void (*dispatch)(int sig));
-extern gboolean mainloop_destroy_signal(int sig); +gboolean +mainloop_destroy_signal(int sig);
-typedef struct trigger_s -{ +typedef struct trigger_s { GSource source; GDestroyNotify dnotify; gboolean trigger; void *user_data; guint id; - } mainloop_trigger_t;
-extern mainloop_trigger_t *mainloop_add_trigger( - int priority, gboolean (*dispatch)(gpointer user_data), gpointer userdata); +mainloop_trigger_t * +mainloop_add_trigger(int priority, gboolean (*dispatch)(gpointer user_data), + gpointer userdata);
-extern void mainloop_set_trigger(mainloop_trigger_t *source); +void +mainloop_set_trigger(mainloop_trigger_t *source);
-extern gboolean mainloop_destroy_trigger(mainloop_trigger_t *source); +gboolean +mainloop_destroy_trigger(mainloop_trigger_t *source);
-typedef struct mainloop_fd_s -{ +typedef struct mainloop_fd_s { GSource source; GPollFD gpoll; guint id; void *user_data; GDestroyNotify dnotify; gboolean (*dispatch)(int fd, gpointer user_data); - } mainloop_fd_t;
-extern mainloop_fd_t *mainloop_add_fd(int priority, int fd, - gboolean (*dispatch)(int fd, gpointer userdata), - GDestroyNotify notify, gpointer userdata); +mainloop_fd_t * +mainloop_add_fd(int priority, int fd, + gboolean (*dispatch)(int fd, gpointer userdata), + GDestroyNotify notify, gpointer userdata);
-extern gboolean mainloop_destroy_fd(mainloop_fd_t* source); +gboolean +mainloop_destroy_fd(mainloop_fd_t* source);
@@ -83,19 +87,18 @@ struct mainloop_child_s {
/* Called when a process dies */ void (*callback)(mainloop_child_t* p, int status, int signo, int exitcode); - };
-extern void mainloop_track_children(int priority); +void +mainloop_track_children(int priority);
/* * Create a new tracked process * To track a process group, use -pid */ -extern void mainloop_add_child(pid_t pid, int timeout, const char *desc, - void *privatedata, - void (*callback)(mainloop_child_t* p, - int status, int signo, - int exitcode)); +void +mainloop_add_child(pid_t pid, int timeout, const char *desc, void *privatedata, + void (*callback)(mainloop_child_t* p, int status, int signo, + int exitcode));
#endif diff --git a/src/include/matahari/network.h b/src/include/matahari/network.h index 89effe4..1249bfd 100644 --- a/src/include/matahari/network.h +++ b/src/include/matahari/network.h @@ -48,7 +48,7 @@ enum mh_network_interface_flags { * * \return the name for the provided network interface */ -extern const char * +const char * mh_network_interface_get_name(const struct mh_network_interface *iface);
/** @@ -76,7 +76,7 @@ mh_network_interface_get_flags(const struct mh_network_interface *iface); * g_list_free_full(iface_list, mh_network_interface_destroy); * \endcode */ -extern void +void mh_network_interface_destroy(gpointer data);
/** @@ -88,7 +88,7 @@ mh_network_interface_destroy(gpointer data); * \return A list of network interfaces. The data for each list item is a * struct mh_network_interface. */ -extern GList * +GList * mh_network_get_interfaces(void);
/** @@ -100,7 +100,7 @@ mh_network_get_interfaces(void); * * \return buf, for convenience */ -extern const char * +const char * mh_network_get_ip_address(const char *iface, char *buf, size_t len);
/** @@ -112,12 +112,17 @@ mh_network_get_ip_address(const char *iface, char *buf, size_t len); * * \return buf, for convenience */ -extern const char * +const char * mh_network_get_mac_address(const char *iface, char *buf, size_t len);
-extern void mh_network_stop(const char *iface); -extern void mh_network_start(const char *iface); -extern void mh_network_restart(const char *iface); +void +mh_network_stop(const char *iface); + +void +mh_network_start(const char *iface); + +void +mh_network_restart(const char *iface);
/** * Get the status of a network interface @@ -131,7 +136,7 @@ extern void mh_network_restart(const char *iface); * \retval non-zero network interface was not found and the value of flags * is undefined. */ -extern int +int mh_network_status(const char *iface, uint64_t *flags);
#endif /* __NETWORK_H */ diff --git a/src/include/matahari/services.h b/src/include/matahari/services.h index e48da77..82d0aa9 100644 --- a/src/include/matahari/services.h +++ b/src/include/matahari/services.h @@ -145,7 +145,7 @@ typedef struct svc_action_s * \return a list of what was found. The list items are gchar *. This list _must_ * be destroyed using g_list_free_full(list, free). */ -extern GList * +GList * get_directory_list(const char *root, gboolean files);
/** @@ -154,7 +154,7 @@ get_directory_list(const char *root, gboolean files); * \return a list of services. The list items are gchar *. This list _must_ * be destroyed using g_list_free_full(list, free). */ -extern GList * +GList * services_list(void);
/** @@ -165,7 +165,7 @@ services_list(void); * \return a list of providers. The list items are gchar *. This list _must_ * be destroyed using g_list_free_full(list, free). */ -extern GList * +GList * resources_list_providers(const char *standard);
/** @@ -177,16 +177,27 @@ resources_list_providers(const char *standard); * \return a list of resource agents. The list items are gchar *. This list _must_ * be destroyed using g_list_free_full(list, free). */ -extern GList * +GList * resources_list_agents(const char *standard, const char *provider);
-extern svc_action_t *services_action_create( - const char *name, const char *action, int interval /* ms */, int timeout /* ms */); +svc_action_t * +services_action_create(const char *name, const char *action, + int interval /* ms */, int timeout /* ms */);
-/* After the call, 'params' is owned, and later free'd by the svc_action_t result */ -extern svc_action_t *resources_action_create( - const char *name, const char *standard, const char *provider, const char *agent, - const char *action, int interval /* ms */, int timeout /* ms */, GHashTable *params); +/** + * Create a resources action. + * + * \param[in] timeout the timeout in milliseconds + * \param[in] interval how often to repeat this action, in milliseconds. + * If this value is 0, only execute this action one time. + * + * \post After the call, 'params' is owned, and later free'd by the svc_action_t result + */ +svc_action_t * +resources_action_create(const char *name, const char *standard, + const char *provider, const char *agent, + const char *action, int interval /* ms */, + int timeout /* ms */, GHashTable *params);
/** * Utilize services API to execute an arbitrary command. @@ -204,9 +215,11 @@ extern svc_action_t *resources_action_create( svc_action_t * mh_services_action_create_generic(const char *exec, const char *args[]);
-extern void services_action_free(svc_action_t *op); +void +services_action_free(svc_action_t *op);
-extern gboolean services_action_sync(svc_action_t *op); +gboolean +services_action_sync(svc_action_t *op);
/** * Run an action asynchronously. @@ -217,11 +230,11 @@ extern gboolean services_action_sync(svc_action_t *op); * \retval TRUE succesfully started execution * \retval FALSE failed to start execution, no callback will be received */ -extern gboolean +gboolean services_action_async(svc_action_t *op, void (*action_callback)(svc_action_t *));
-extern gboolean services_action_cancel(const char *name, const char *action, - int interval); +gboolean +services_action_cancel(const char *name, const char *action, int interval);
static inline enum ocf_exitcode services_get_ocf_exitcode(char *action, int lsb_exitcode) diff --git a/src/include/matahari/sysconfig.h b/src/include/matahari/sysconfig.h index a5bfd04..21a59eb 100644 --- a/src/include/matahari/sysconfig.h +++ b/src/include/matahari/sysconfig.h @@ -56,7 +56,7 @@ typedef void (*mh_sysconfig_result_cb)(void *data, int res); * \retval 0 for success * \retval -1 for failure */ -extern int +int mh_sysconfig_run_uri(const char *uri, uint32_t flags, const char *scheme, const char *key, mh_sysconfig_result_cb result_cb, void *cb_data);
@@ -76,7 +76,7 @@ mh_sysconfig_run_uri(const char *uri, uint32_t flags, const char *scheme, const * \retval 0 for success * \retval -1 for failure */ -extern int +int mh_sysconfig_run_string(const char *string, uint32_t flags, const char *scheme, const char *key, mh_sysconfig_result_cb result_cb, void *cb_data); @@ -90,7 +90,7 @@ mh_sysconfig_run_string(const char *string, uint32_t flags, const char *scheme, * * \return DATA of returned query result */ -extern const char * +const char * mh_sysconfig_query(const char *query, uint32_t flags, const char *scheme);
/** @@ -102,7 +102,7 @@ mh_sysconfig_query(const char *query, uint32_t flags, const char *scheme); * \retval 1 if writing to file suceeds * \retval 0 failed to write to file */ -extern gboolean +gboolean mh_sysconfig_set_configured(const char *key, const char *contents);
/** @@ -114,7 +114,7 @@ mh_sysconfig_set_configured(const char *key, const char *contents); * * \return STATUS of key */ -extern char * +char * mh_sysconfig_is_configured(const char *key);
#endif // __MH_SYSCONFIG_H__ diff --git a/src/include/matahari/sysconfig_internal.h b/src/include/matahari/sysconfig_internal.h index 48879ad..1495737 100644 --- a/src/include/matahari/sysconfig_internal.h +++ b/src/include/matahari/sysconfig_internal.h @@ -41,7 +41,7 @@ * * \return nothing */ -extern void +void mh_sysconfig_keys_dir_set(const char *path);
#endif /* __MH_SYSCONFIG_INTERNAL_H__ */ diff --git a/src/include/matahari/utilities.h b/src/include/matahari/utilities.h index 4f73b08..cea0c3b 100644 --- a/src/include/matahari/utilities.h +++ b/src/include/matahari/utilities.h @@ -32,22 +32,31 @@ #include <string.h> #include <glib.h>
-extern const char *mh_uuid(void); -extern const char *mh_hostname(void); -extern const char *mh_domainname(void); +const char * +mh_uuid(void); + +const char * +mh_hostname(void); + +const char * +mh_domainname(void);
/** * Get the local dnsdomainname. */ -extern const char * +const char * mh_dnsdomainname(void);
-extern char *mh_file_first_line(const char *file); -extern void mh_abort(const char *file, const char *function, int line, - const char *assert_condition, int do_core, int do_fork); +char * +mh_file_first_line(const char *file); + +void +mh_abort(const char *file, const char *function, int line, + const char *assert_condition, int do_core, int do_fork);
#ifdef WIN32 -extern wchar_t *char2wide(const char *str); +wchar_t * +char2wide(const char *str); #endif
#ifndef HAVE_ASPRINTF @@ -58,7 +67,8 @@ extern wchar_t *char2wide(const char *str); * asprintf() on the system. For more information on how to use asprintf(), * see its man page. */ -extern int asprintf(char **ret, const char *fmt, ...); +int +asprintf(char **ret, const char *fmt, ...); #endif
#ifndef HAVE_G_LIST_FREE_FULL @@ -68,7 +78,8 @@ extern int asprintf(char **ret, const char *fmt, ...); * This version of g_list_free_full() is only used when the build system * doesn't find g_list_free_full() on the system. */ -extern void g_list_free_full(GList *list, GDestroyNotify free_func); +void +g_list_free_full(GList *list, GDestroyNotify free_func); #endif
#define DIMOF(a) ((int) (sizeof(a) / sizeof(0[a]))) diff --git a/src/lib/host_private.h b/src/lib/host_private.h index 1ddc241..009dda6 100644 --- a/src/lib/host_private.h +++ b/src/lib/host_private.h @@ -31,13 +31,13 @@
#include <glib.h>
-extern const char * +const char * host_os_get_cpu_flags(void);
-extern void +void host_os_reboot(void);
-extern void +void host_os_shutdown(void);
/** @@ -46,14 +46,22 @@ host_os_shutdown(void); * \retval 0 success * \retval non-zero failure */ -extern int +int host_os_identify(void);
-extern char *host_os_machine_uuid(void); -extern char *host_os_custom_uuid(void); -extern char *host_os_reboot_uuid(void); -extern const char *host_os_agent_uuid(void); +char * +host_os_machine_uuid(void);
-extern int host_os_set_custom_uuid(const char *uuid); +char * +host_os_custom_uuid(void); + +char * +host_os_reboot_uuid(void); + +const char * +host_os_agent_uuid(void); + +int +host_os_set_custom_uuid(const char *uuid);
#endif /* __MH_HOST_PRIVATE_H__ */ diff --git a/src/lib/network_private.h b/src/lib/network_private.h index 859e63d..60b1b71 100644 --- a/src/lib/network_private.h +++ b/src/lib/network_private.h @@ -16,7 +16,15 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#ifndef __MH_NETWORK_PRIVATE_H__ +#define __MH_NETWORK_PRIVATE_H__ + #include <glib.h>
-extern void network_os_stop(const char *iface); -extern void network_os_start(const char *iface); +void +network_os_stop(const char *iface); + +void +network_os_start(const char *iface); + +#endif /* __MH_NETWORK_PRIVATE_H__ */ diff --git a/src/lib/services_private.h b/src/lib/services_private.h index 5a147ef..d7931dc 100644 --- a/src/lib/services_private.h +++ b/src/lib/services_private.h @@ -1,5 +1,25 @@ -struct svc_action_private_s -{ +/* + * Copyright (C) 2010 - 2011, Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __MH_SERVICES_PRIVATE_H__ +#define __MH_SERVICES_PRIVATE_H__ + +struct svc_action_private_s { char *exec; char *args[4];
@@ -13,10 +33,22 @@ struct svc_action_private_s mainloop_fd_t *stdout_gsource; };
-extern GList *services_os_get_directory_list(const char *root, gboolean files); -extern gboolean services_os_action_execute(svc_action_t* op, - gboolean synchronous); -extern void services_os_set_exec(svc_action_t* op); -extern GList *services_os_list(void); -extern GList *resources_os_list_ocf_providers(void); -extern GList *resources_os_list_ocf_agents(const char *provider); +GList * +services_os_get_directory_list(const char *root, gboolean files); + +gboolean +services_os_action_execute(svc_action_t *op, gboolean synchronous); + +void +services_os_set_exec(svc_action_t *op); + +GList * +services_os_list(void); + +GList * +resources_os_list_ocf_providers(void); + +GList * +resources_os_list_ocf_agents(const char *provider); + +#endif /* __MH_SERVICES_PRIVATE_H__ */ diff --git a/src/lib/sysconfig_private.h b/src/lib/sysconfig_private.h index 36dc554..fb49905 100644 --- a/src/lib/sysconfig_private.h +++ b/src/lib/sysconfig_private.h @@ -19,15 +19,17 @@ #ifndef __MH_SYSCONFIG_PRIVATE_H_ #define __MH_SYSCONFIG_PRIVATE_H_
-extern int +int sysconfig_os_run_uri(const char *uri, uint32_t flags, const char *scheme, - const char *key, mh_sysconfig_result_cb result_cb, void *cb_data); + const char *key, mh_sysconfig_result_cb result_cb, + void *cb_data);
-extern int +int sysconfig_os_run_string(const char *string, uint32_t flags, const char *scheme, - const char *key, mh_sysconfig_result_cb result_cb, void *cb_data); + const char *key, mh_sysconfig_result_cb result_cb, + void *cb_data);
-extern const char * +const char * sysconfig_os_query(const char *query, uint32_t flags, const char *scheme);
#endif /* __MH_SYSCONFIG_PRIVATE_H_ */ diff --git a/src/tests/mh_test_utilities.h b/src/tests/mh_test_utilities.h index 4b1b4a4..8ea66ff 100644 --- a/src/tests/mh_test_utilities.h +++ b/src/tests/mh_test_utilities.h @@ -31,6 +31,7 @@ * * \return 0 or greater for successful match */ -extern int mh_test_is_match(const char *pattern, const char *subject); +int +mh_test_is_match(const char *pattern, const char *subject);
#endif /* __MH_TEST_UTILITIES */
matahari@lists.fedorahosted.org