From b72d521340383b6418fa6a75faca3bc45f06b14a Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 11 Feb 2009 10:43:25 +0100 Subject: [PATCH] Document unused parameters. In all cases where unused parameters have to exist either because some API requires it or for more consistency, they now have been documented using __attribute__((unused)) (which is automatically disabled in case GCC is not used to prevent problems with compilers not supporting attributes). In a few other cases, the parameters have been removed. This allows the use of -Wunused-parameter (which is enabled by -Wextra as well, when using -Wall). --- src/apache.c | 2 +- src/ascent.c | 2 +- src/battery.c | 4 ++-- src/bind.c | 2 +- src/collectd.c | 8 ++++---- src/collectdmon.c | 8 ++++++-- src/dns.c | 2 +- src/email.c | 2 +- src/exec.c | 2 +- src/filter_chain.c | 18 ++++++++++++------ src/ipmi.c | 14 +++++++------- src/match_regex.c | 6 ++++-- src/match_value.c | 2 +- src/netlink.c | 6 +++--- src/network.c | 7 ++++--- src/nginx.c | 3 ++- src/notify_email.c | 7 ++++--- src/plugin.c | 2 +- src/rrdtool.c | 4 ++-- src/snmp.c | 2 +- src/target_notification.c | 2 +- src/target_replace.c | 2 +- src/target_set.c | 2 +- src/teamspeak2.c | 4 ++-- src/thermal.c | 8 ++++---- src/unixsock.c | 2 +- src/utils_dns.c | 14 +++++--------- src/utils_match.c | 2 +- src/utils_tail_match.c | 3 ++- src/utils_threshold.c | 2 +- 30 files changed, 78 insertions(+), 66 deletions(-) diff --git a/src/apache.c b/src/apache.c index 7dc34f5b..091d5947 100644 --- a/src/apache.c +++ b/src/apache.c @@ -55,7 +55,7 @@ static const char *config_keys[] = static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); static size_t apache_curl_callback (void *buf, size_t size, size_t nmemb, - void *stream) + void __attribute__((unused)) *stream) { size_t len = size * nmemb; diff --git a/src/ascent.c b/src/ascent.c index bf1e9f4a..54341c77 100644 --- a/src/ascent.c +++ b/src/ascent.c @@ -143,7 +143,7 @@ static int ascent_submit_gauge (const char *plugin_instance, /* {{{ */ } /* }}} int ascent_submit_gauge */ static size_t ascent_curl_callback (void *buf, size_t size, size_t nmemb, /* {{{ */ - void *stream) + void __attribute__((unused)) *stream) { size_t len = size * nmemb; diff --git a/src/battery.c b/src/battery.c index d142982d..272193ee 100644 --- a/src/battery.c +++ b/src/battery.c @@ -314,8 +314,8 @@ static void get_via_generic_iokit (double *ret_charge, #endif /* HAVE_IOKIT_IOKITLIB_H */ #if KERNEL_LINUX -static int battery_read_acpi (const char *dir, const char *name, - void *user_data) +static int battery_read_acpi (const char __attribute__((unused)) *dir, + const char *name, void __attribute__((unused)) *user_data) { double current = INVALID_VALUE; double voltage = INVALID_VALUE; diff --git a/src/bind.c b/src/bind.c index f9de8e6a..8cd11165 100644 --- a/src/bind.c +++ b/src/bind.c @@ -281,7 +281,7 @@ static void submit_counter(time_t ts, const char *plugin_instance, const char *t } /* void submit_counter */ static size_t bind_curl_callback (void *buf, size_t size, size_t nmemb, - void *stream) + void __attribute__((unused)) *stream) { size_t len = size * nmemb; diff --git a/src/collectd.c b/src/collectd.c index 17905c74..576abef4 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -47,7 +47,7 @@ kstat_ctl_t *kc; static int loop = 0; -static void *do_flush (void *arg) +static void *do_flush (void __attribute__((unused)) *arg) { INFO ("Flushing all data."); plugin_flush (NULL, -1, NULL); @@ -56,17 +56,17 @@ static void *do_flush (void *arg) return NULL; } -static void sig_int_handler (int signal) +static void sig_int_handler (int __attribute__((unused)) signal) { loop++; } -static void sig_term_handler (int signal) +static void sig_term_handler (int __attribute__((unused)) signal) { loop++; } -static void sig_usr1_handler (int signal) +static void sig_usr1_handler (int __attribute__((unused)) signal) { pthread_t thread; pthread_attr_t attr; diff --git a/src/collectdmon.c b/src/collectdmon.c index 015344f9..078b2eb1 100644 --- a/src/collectdmon.c +++ b/src/collectdmon.c @@ -19,6 +19,10 @@ * Sebastian Harl **/ +#if !defined(__GNUC__) || !__GNUC__ +# define __attribute__(x) /**/ +#endif + #include "config.h" #include @@ -197,13 +201,13 @@ static int collectd_stop (void) return 0; } /* collectd_stop */ -static void sig_int_term_handler (int signo) +static void sig_int_term_handler (int __attribute__((unused)) signo) { ++loop; return; } /* sig_int_term_handler */ -static void sig_hup_handler (int signo) +static void sig_hup_handler (int __attribute__((unused)) signo) { ++restart; return; diff --git a/src/dns.c b/src/dns.c index d82cbd86..ab38789f 100644 --- a/src/dns.c +++ b/src/dns.c @@ -195,7 +195,7 @@ static void dns_child_callback (const rfc1035_header_t *dns) pthread_mutex_unlock (&opcode_mutex); } -static void *dns_child_loop (void *dummy) +static void *dns_child_loop (void __attribute__((unused)) *dummy) { pcap_t *pcap_obj; char pcap_error[PCAP_ERRBUF_SIZE]; diff --git a/src/email.c b/src/email.c index ff9d4394..f79217cb 100644 --- a/src/email.c +++ b/src/email.c @@ -378,7 +378,7 @@ static void *collect (void *arg) pthread_exit ((void *)0); } /* static void *collect (void *) */ -static void *open_connection (void *arg) +static void *open_connection (void __attribute__((unused)) *arg) { struct sockaddr_un addr; diff --git a/src/exec.c b/src/exec.c index a78f902f..8add480e 100644 --- a/src/exec.c +++ b/src/exec.c @@ -78,7 +78,7 @@ static pthread_mutex_t pl_lock = PTHREAD_MUTEX_INITIALIZER; /* * Functions */ -static void sigchld_handler (int signal) /* {{{ */ +static void sigchld_handler (int __attribute__((unused)) signal) /* {{{ */ { pid_t pid; int status; diff --git a/src/filter_chain.c b/src/filter_chain.c index 6d0bca7b..4c324a80 100644 --- a/src/filter_chain.c +++ b/src/filter_chain.c @@ -609,7 +609,8 @@ static int fc_bit_jump_destroy (void **user_data) /* {{{ */ } /* }}} int fc_bit_jump_destroy */ static int fc_bit_jump_invoke (const data_set_t *ds, /* {{{ */ - value_list_t *vl, notification_meta_t **meta, void **user_data) + value_list_t *vl, notification_meta_t __attribute__((unused)) **meta, + void **user_data) { char *chain_name; fc_chain_t *chain; @@ -637,14 +638,18 @@ static int fc_bit_jump_invoke (const data_set_t *ds, /* {{{ */ return (FC_TARGET_CONTINUE); } /* }}} int fc_bit_jump_invoke */ -static int fc_bit_stop_invoke (const data_set_t *ds, /* {{{ */ - value_list_t *vl, notification_meta_t **meta, void **user_data) +static int fc_bit_stop_invoke (const data_set_t __attribute__((unused)) *ds, /* {{{ */ + value_list_t __attribute__((unused)) *vl, + notification_meta_t __attribute__((unused)) **meta, + void __attribute__((unused)) **user_data) { return (FC_TARGET_STOP); } /* }}} int fc_bit_stop_invoke */ -static int fc_bit_return_invoke (const data_set_t *ds, /* {{{ */ - value_list_t *vl, notification_meta_t **meta, void **user_data) +static int fc_bit_return_invoke (const data_set_t __attribute__((unused)) *ds, /* {{{ */ + value_list_t __attribute__((unused)) *vl, + notification_meta_t __attribute__((unused)) **meta, + void __attribute__((unused)) **user_data) { return (FC_TARGET_RETURN); } /* }}} int fc_bit_return_invoke */ @@ -726,7 +731,8 @@ static int fc_bit_write_destroy (void **user_data) /* {{{ */ } /* }}} int fc_bit_write_destroy */ static int fc_bit_write_invoke (const data_set_t *ds, /* {{{ */ - value_list_t *vl, notification_meta_t **meta, void **user_data) + value_list_t *vl, notification_meta_t __attribute__((unused)) **meta, + void **user_data) { char **plugin_list; int status; diff --git a/src/ipmi.c b/src/ipmi.c index 10590705..0b79823d 100644 --- a/src/ipmi.c +++ b/src/ipmi.c @@ -111,9 +111,9 @@ static int sensor_list_remove (ipmi_sensor_t *sensor); static void sensor_read_handler (ipmi_sensor_t *sensor, int err, enum ipmi_value_present_e value_present, - unsigned int raw_value, + unsigned int __attribute__((unused)) raw_value, double value, - ipmi_states_t *states, + ipmi_states_t __attribute__((unused)) *states, void *user_data) { value_t values[1]; @@ -459,9 +459,9 @@ static int sensor_list_remove_all (void) * Entity handlers */ static void entity_sensor_update_handler (enum ipmi_update_e op, - ipmi_entity_t *entity, + ipmi_entity_t __attribute__((unused)) *entity, ipmi_sensor_t *sensor, - void *user_data) + void __attribute__((unused)) *user_data) { /* TODO: Ignore sensors we cannot read */ @@ -480,9 +480,9 @@ static void entity_sensor_update_handler (enum ipmi_update_e op, * Domain handlers */ static void domain_entity_update_handler (enum ipmi_update_e op, - ipmi_domain_t *domain, + ipmi_domain_t __attribute__((unused)) *domain, ipmi_entity_t *entity, - void *user_data) + void __attribute__((unused)) *user_data) { int status; @@ -574,7 +574,7 @@ static int thread_init (os_handler_t **ret_os_handler) return (0); } /* int thread_init */ -static void *thread_main (void *user_data) +static void *thread_main (void __attribute__((unused)) *user_data) { int status; os_handler_t *os_handler = NULL; diff --git a/src/match_regex.c b/src/match_regex.c index 9233d803..1fca8898 100644 --- a/src/match_regex.c +++ b/src/match_regex.c @@ -257,8 +257,10 @@ static int mr_destroy (void **user_data) /* {{{ */ return (0); } /* }}} int mr_destroy */ -static int mr_match (const data_set_t *ds, const value_list_t *vl, /* {{{ */ - notification_meta_t **meta, void **user_data) +static int mr_match (const data_set_t __attribute__((unused)) *ds, /* {{{ */ + const value_list_t *vl, + notification_meta_t __attribute__((unused)) **meta, + void **user_data) { mr_match_t *m; diff --git a/src/match_value.c b/src/match_value.c index a3eeffd4..9f02226b 100644 --- a/src/match_value.c +++ b/src/match_value.c @@ -258,7 +258,7 @@ static int mv_destroy (void **user_data) /* {{{ */ } /* }}} int mv_destroy */ static int mv_match (const data_set_t *ds, const value_list_t *vl, /* {{{ */ - notification_meta_t **meta, void **user_data) + notification_meta_t __attribute__((unused)) **meta, void **user_data) { mv_match_t *m; gauge_t *values; diff --git a/src/netlink.c b/src/netlink.c index d7d1a269..8f45ea2e 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -204,8 +204,8 @@ static void submit_two (const char *dev, const char *type, plugin_dispatch_values (&vl); } /* void submit_two */ -static int link_filter (const struct sockaddr_nl *sa, - struct nlmsghdr *nmh, void *args) +static int link_filter (const struct sockaddr_nl __attribute__((unused)) *sa, + struct nlmsghdr *nmh, void __attribute__((unused)) *args) { struct ifinfomsg *msg; int msg_len; @@ -314,7 +314,7 @@ static int link_filter (const struct sockaddr_nl *sa, return (0); } /* int link_filter */ -static int qos_filter (const struct sockaddr_nl *sa, +static int qos_filter (const struct sockaddr_nl __attribute__((unused)) *sa, struct nlmsghdr *nmh, void *args) { struct tcmsg *msg; diff --git a/src/network.c b/src/network.c index 34f89d96..e0800004 100644 --- a/src/network.c +++ b/src/network.c @@ -1240,7 +1240,7 @@ static int network_add_sending_socket (const char *node, const char *service) return (0); } /* int network_get_listen_socket */ -static void *dispatch_thread (void *arg) +static void *dispatch_thread (void __attribute__((unused)) *arg) { while (42) { @@ -1391,7 +1391,7 @@ static int network_receive (void) return (0); } -static void *receive_thread (void *arg) +static void *receive_thread (void __attribute__((unused)) *arg) { return (network_receive () ? (void *) 1 : (void *) 0); } /* void *receive_thread */ @@ -1808,7 +1808,8 @@ static int network_init (void) * just send the buffer if `flush' is called - if the requested value was in * there, good. If not, well, then there is nothing to flush.. -octo */ -static int network_flush (int timeout, const char *identifier) +static int network_flush (int timeout, + const char __attribute__((unused)) *identifier) { pthread_mutex_lock (&send_buffer_lock); diff --git a/src/nginx.c b/src/nginx.c index 8cb76285..dfa4f983 100644 --- a/src/nginx.c +++ b/src/nginx.c @@ -52,7 +52,8 @@ static const char *config_keys[] = }; static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); -static size_t nginx_curl_callback (void *buf, size_t size, size_t nmemb, void *stream) +static size_t nginx_curl_callback (void *buf, size_t size, size_t nmemb, + void __attribute__((unused)) *stream) { size_t len = size * nmemb; diff --git a/src/notify_email.c b/src/notify_email.c index dc4e47f7..32bd9164 100644 --- a/src/notify_email.c +++ b/src/notify_email.c @@ -61,7 +61,7 @@ static char *email_subject = NULL; /* Callback to get username and password */ static int authinteract (auth_client_request_t request, char **result, - int fields, void *arg) + int fields, void __attribute__((unused)) *arg) { int i; for (i = 0; i < fields; i++) @@ -78,7 +78,7 @@ static int authinteract (auth_client_request_t request, char **result, /* Callback to print the recipient status */ static void print_recipient_status (smtp_recipient_t recipient, - const char *mailbox, void *arg) + const char *mailbox, void __attribute__((unused)) *arg) { const smtp_status_t *status; @@ -90,7 +90,8 @@ static void print_recipient_status (smtp_recipient_t recipient, } /* void print_recipient_status */ /* Callback to monitor SMTP activity */ -static void monitor_cb (const char *buf, int buflen, int writing, void *arg) +static void monitor_cb (const char *buf, int buflen, int writing, + void __attribute__((unused)) *arg) { char log_str[MAXSTRING]; diff --git a/src/plugin.c b/src/plugin.c index 4aabebe3..9d558cb1 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -171,7 +171,7 @@ static int plugin_load_file (char *file) return (0); } -static void *plugin_read_thread (void *args) +static void *plugin_read_thread (void __attribute__((unused)) *args) { llentry_t *le; read_func_t *rf; diff --git a/src/rrdtool.c b/src/rrdtool.c index 95bde694..debb7bd4 100644 --- a/src/rrdtool.c +++ b/src/rrdtool.c @@ -223,7 +223,7 @@ static int value_list_to_string (char *buffer, int buffer_len, } /* int value_list_to_string */ static int value_list_to_filename (char *buffer, int buffer_len, - const data_set_t *ds, const value_list_t *vl) + const data_set_t __attribute__((unused)) *ds, const value_list_t *vl) { int offset = 0; int status; @@ -266,7 +266,7 @@ static int value_list_to_filename (char *buffer, int buffer_len, return (0); } /* int value_list_to_filename */ -static void *rrd_queue_thread (void *data) +static void *rrd_queue_thread (void __attribute__((unused)) *data) { struct timeval tv_next_update; struct timeval tv_now; diff --git a/src/snmp.c b/src/snmp.c index 44fce620..82fd6583 100644 --- a/src/snmp.c +++ b/src/snmp.c @@ -1451,7 +1451,7 @@ static int csnmp_read_host (host_definition_t *host) return (0); } /* int csnmp_read_host */ -static void *csnmp_read_thread (void *data) +static void *csnmp_read_thread (void __attribute__((unused)) *data) { host_definition_t *host; diff --git a/src/target_notification.c b/src/target_notification.c index f77d3387..9ee1518a 100644 --- a/src/target_notification.c +++ b/src/target_notification.c @@ -223,7 +223,7 @@ static int tn_create (const oconfig_item_t *ci, void **user_data) /* {{{ */ } /* }}} int tn_create */ static int tn_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ - notification_meta_t **meta, void **user_data) + notification_meta_t __attribute__((unused)) **meta, void **user_data) { tn_data_t *data; notification_t n; diff --git a/src/target_replace.c b/src/target_replace.c index 6e72f31b..3f983c86 100644 --- a/src/target_replace.c +++ b/src/target_replace.c @@ -353,7 +353,7 @@ static int tr_create (const oconfig_item_t *ci, void **user_data) /* {{{ */ } /* }}} int tr_create */ static int tr_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ - notification_meta_t **meta, void **user_data) + notification_meta_t __attribute__((unused)) **meta, void **user_data) { tr_data_t *data; diff --git a/src/target_set.c b/src/target_set.c index 70b0fdfc..19ff7b92 100644 --- a/src/target_set.c +++ b/src/target_set.c @@ -228,7 +228,7 @@ static int ts_create (const oconfig_item_t *ci, void **user_data) /* {{{ */ } /* }}} int ts_create */ static int ts_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ - notification_meta_t **meta, void **user_data) + notification_meta_t __attribute__((unused)) **meta, void **user_data) { ts_data_t *data; diff --git a/src/teamspeak2.c b/src/teamspeak2.c index e81dbe30..d4bf2aa4 100644 --- a/src/teamspeak2.c +++ b/src/teamspeak2.c @@ -406,7 +406,7 @@ static int tss2_select_vserver (FILE *read_fh, FILE *write_fh, vserver_list_t *v } /* int tss2_select_vserver */ static int tss2_vserver_gapl (FILE *read_fh, FILE *write_fh, - vserver_list_t *vserver, gauge_t *ret_value) + gauge_t *ret_value) { /* * Reads the vserver's average packet loss and submits it to collectd. @@ -677,7 +677,7 @@ static int tss2_read_vserver (vserver_list_t *vserver) * with an error. */ if ((status == 0) && (vserver != NULL)) { - status = tss2_vserver_gapl (read_fh, write_fh, vserver, &packet_loss); + status = tss2_vserver_gapl (read_fh, write_fh, &packet_loss); if (status == 0) { valid |= 0x20; diff --git a/src/thermal.c b/src/thermal.c index 79033b17..2ea6a24f 100644 --- a/src/thermal.c +++ b/src/thermal.c @@ -60,8 +60,8 @@ static void thermal_submit (const char *plugin_instance, enum dev_type dt, plugin_dispatch_values (&vl); } -static int thermal_sysfs_device_read (const char *dir, const char *name, - void *user_data) +static int thermal_sysfs_device_read (const char __attribute__((unused)) *dir, + const char *name, void __attribute__((unused)) *user_data) { char filename[256]; char data[1024]; @@ -112,8 +112,8 @@ static int thermal_sysfs_device_read (const char *dir, const char *name, return ok ? 0 : -1; } -static int thermal_procfs_device_read (const char *dir, const char *name, - void *user_data) +static int thermal_procfs_device_read (const char __attribute__((unused)) *dir, + const char *name, void __attribute__((unused)) *user_data) { const char str_temp[] = "temperature:"; char filename[256]; diff --git a/src/unixsock.c b/src/unixsock.c index 3bdd8c27..57f34501 100644 --- a/src/unixsock.c +++ b/src/unixsock.c @@ -278,7 +278,7 @@ static void *us_handle_client (void *arg) return ((void *) 0); } /* void *us_handle_client */ -static void *us_server_thread (void *arg) +static void *us_server_thread (void __attribute__((unused)) *arg) { int status; int *remote_fd; diff --git a/src/utils_dns.c b/src/utils_dns.c index c16b3c12..b7dc7913 100644 --- a/src/utils_dns.c +++ b/src/utils_dns.c @@ -337,9 +337,7 @@ rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns } static int -handle_dns(const char *buf, int len, - const struct in6_addr *s_addr, - const struct in6_addr *d_addr) +handle_dns(const char *buf, int len) { rfc1035_header_t qh; uint16_t us; @@ -412,16 +410,14 @@ handle_dns(const char *buf, int len, } static int -handle_udp(const struct udphdr *udp, int len, - const struct in6_addr *s_addr, - const struct in6_addr *d_addr) +handle_udp(const struct udphdr *udp, int len) { char buf[PCAP_SNAPLEN]; if ((ntohs (udp->UDP_DEST) != 53) && (ntohs (udp->UDP_SRC) != 53)) return 0; memcpy(buf, udp + 1, len - sizeof(*udp)); - if (0 == handle_dns(buf, len - sizeof(*udp), s_addr, d_addr)) + if (0 == handle_dns(buf, len - sizeof(*udp))) return 0; return 1; } @@ -492,7 +488,7 @@ handle_ipv6 (struct ip6_hdr *ipv6, int len) return (0); memcpy (buf, (char *) ipv6 + offset, payload_len); - if (handle_udp ((struct udphdr *) buf, payload_len, &s_addr, &d_addr) == 0) + if (handle_udp ((struct udphdr *) buf, payload_len) == 0) return (0); return (1); /* Success */ @@ -516,7 +512,7 @@ handle_ip(const struct ip *ip, int len) if (IPPROTO_UDP != ip->ip_p) return 0; memcpy(buf, (void *) ip + offset, len - offset); - if (0 == handle_udp((struct udphdr *) buf, len - offset, &s_addr, &d_addr)) + if (0 == handle_udp((struct udphdr *) buf, len - offset)) return 0; return 1; } diff --git a/src/utils_match.c b/src/utils_match.c index 9e75e4e2..906d7c70 100644 --- a/src/utils_match.c +++ b/src/utils_match.c @@ -68,7 +68,7 @@ static char *match_substr (const char *str, int begin, int end) return (ret); } /* char *match_substr */ -static int default_callback (const char *str, +static int default_callback (const char __attribute__((unused)) *str, char * const *matches, size_t matches_num, void *user_data) { cu_match_value_t *data = (cu_match_value_t *) user_data; diff --git a/src/utils_tail_match.c b/src/utils_tail_match.c index 26e95311..ae1f4f75 100644 --- a/src/utils_tail_match.c +++ b/src/utils_tail_match.c @@ -99,7 +99,8 @@ static int simple_submit_match (cu_match_t *match, void *user_data) return (0); } /* int simple_submit_match */ -static int tail_callback (void *data, char *buf, int buflen) +static int tail_callback (void *data, char *buf, + int __attribute__((unused)) buflen) { cu_tail_match_t *obj = (cu_tail_match_t *) data; int i; diff --git a/src/utils_threshold.c b/src/utils_threshold.c index fd6257c5..1b211385 100644 --- a/src/utils_threshold.c +++ b/src/utils_threshold.c @@ -689,7 +689,7 @@ static int ut_report_state (const data_set_t *ds, * Does not fail. */ static int ut_check_one_data_source (const data_set_t *ds, - const value_list_t *vl, + const value_list_t __attribute__((unused)) *vl, const threshold_t *th, const gauge_t *values, int ds_index) -- 2.30.2