From 649df8e2da6e43fdf3e0cf2dc08fd44865195f53 Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Sun, 19 Nov 2023 11:04:24 -0700 Subject: [PATCH] fix tab vs space Problem: There was iconsistent use of tab vs space in all code. Solution: Untabify files. --- src/cerebro-admin/cerebro-admin.c | 6 +- src/cerebro-stat/cerebro-stat.c | 12 +- src/cerebrod/cerebrod.c | 2 +- src/cerebrod/cerebrod_config.c | 48 +- src/cerebrod/cerebrod_daemon.c | 4 +- src/cerebrod/cerebrod_debug.h | 2 +- .../cerebrod_event_node_timeout_monitor.c | 2 +- src/cerebrod/cerebrod_event_server.c | 4 +- src/cerebrod/cerebrod_event_update.c | 16 +- src/cerebrod/cerebrod_listener.c | 24 +- src/cerebrod/cerebrod_listener_data.c | 20 +- src/cerebrod/cerebrod_metric_controller.c | 2 +- src/cerebrod/cerebrod_metric_server.c | 4 +- src/cerebrod/cerebrod_monitor_update.c | 22 +- src/cerebrod/cerebrod_speaker.c | 136 ++--- src/cerebrod/cerebrod_speaker_data.c | 2 +- src/cerebrod/cerebrod_util.c | 14 +- src/libs/cerebro/cerebro.c | 2 +- src/libs/cerebro/cerebro_nodelist_util.c | 2 +- src/libs/cerebro/cerebro_nodelist_util.h | 2 +- src/libs/include/cerebro.h | 4 +- src/libs/modules/clusterlist_module.c | 6 +- src/libs/modules/clusterlist_module.h | 6 +- src/libs/modules/config_module.h | 2 +- src/libs/modules/metric_module.c | 12 +- src/libs/modules/metric_module.h | 12 +- src/libs/modules/monitor_module.c | 10 +- src/libs/modules/monitor_module.h | 10 +- src/libs/util/config_util.c | 574 +++++++++--------- src/libs/wrappers/wrappers.c | 50 +- src/libs/wrappers/wrappers.h | 2 +- .../cerebro_clusterlist_genders_util.c | 8 +- src/modules/metric/cerebro_metric_bytesin.c | 4 +- src/modules/metric/cerebro_metric_loadavg.c | 36 +- src/modules/metric/cerebro_metric_loadavg.h | 4 +- src/modules/metric/cerebro_metric_memfree.c | 6 +- src/modules/metric/cerebro_metric_memory.c | 36 +- src/modules/metric/cerebro_metric_memory.h | 6 +- src/modules/metric/cerebro_metric_memtotal.c | 6 +- src/modules/metric/cerebro_metric_memused.c | 6 +- src/modules/metric/cerebro_metric_network.c | 234 +++---- src/modules/metric/cerebro_metric_packetsin.c | 4 +- .../metric/cerebro_metric_packetsout.c | 4 +- src/modules/metric/cerebro_metric_rxerrs.c | 4 +- src/modules/metric/cerebro_metric_swapfree.c | 6 +- src/modules/metric/cerebro_metric_swaptotal.c | 6 +- src/modules/metric/cerebro_metric_swapused.c | 6 +- src/modules/metric/cerebro_metric_txerrs.c | 4 +- 48 files changed, 697 insertions(+), 697 deletions(-) diff --git a/src/cerebro-admin/cerebro-admin.c b/src/cerebro-admin/cerebro-admin.c index f60e0e54..7fe62c85 100644 --- a/src/cerebro-admin/cerebro-admin.c +++ b/src/cerebro-admin/cerebro-admin.c @@ -117,11 +117,11 @@ static void _usage(void) { fprintf(stderr, - "Usage: cerebro_admin [OPTIONS] -m [-r | -u | -p | -s]\n" + "Usage: cerebro_admin [OPTIONS] -m [-r | -u | -p | -s]\n" "\n" "OPTIONS:\n" - " -h Print help and exit\n" - " -v Print version and exit\n" + " -h Print help and exit\n" + " -v Print version and exit\n" " -m STRING Specify the metric name\n" " -r Register the metric name\n" " -u Unregister the metric name\n" diff --git a/src/cerebro-stat/cerebro-stat.c b/src/cerebro-stat/cerebro-stat.c index 87d239a0..fc14a247 100644 --- a/src/cerebro-stat/cerebro-stat.c +++ b/src/cerebro-stat/cerebro-stat.c @@ -138,16 +138,16 @@ static void _usage(void) { fprintf(stderr, - "Usage: cerebro-stat [OPTIONS] -m \n" - "or cerebro-stat [OPTIONS] -l\n" + "Usage: cerebro-stat [OPTIONS] -m \n" + "or cerebro-stat [OPTIONS] -l\n" "or cerebro-stat [OPTIONS] -e \n" "or cerebro-stat [OPTIONS] -z\n" "\n" "OPTIONS:\n" - " -h Print help and exit\n" - " -v Print version and exit\n" - " -o STRING Cerebro server hostname\n" - " -p INT Cerebro server port\n" + " -h Print help and exit\n" + " -v Print version and exit\n" + " -o STRING Cerebro server hostname\n" + " -p INT Cerebro server port\n" " -m STRING Output metric data for the specified metric\n" " -l List all available metrics that can be queried\n" " -U Only output metrics from up nodes\n" diff --git a/src/cerebrod/cerebrod.c b/src/cerebrod/cerebrod.c index aec07540..01157a67 100644 --- a/src/cerebrod/cerebrod.c +++ b/src/cerebrod/cerebrod.c @@ -260,5 +260,5 @@ main(int argc, char **argv) for (;;) sleep(INT_MAX); - return 0; /* NOT REACHED */ + return 0; /* NOT REACHED */ } diff --git a/src/cerebrod/cerebrod_config.c b/src/cerebrod/cerebrod_config.c index 9c84921e..f69d349c 100644 --- a/src/cerebrod/cerebrod_config.c +++ b/src/cerebrod/cerebrod_config.c @@ -154,7 +154,7 @@ _usage(void) "-v --version Output Version\n" "-c --config_file Specify alternate config file\n" "-d --debug Turn on debugging and run daemon\n" - " in foreground\n"); + " in foreground\n"); exit(0); } @@ -500,23 +500,23 @@ _cerebrod_config_error_check_network_interface(char *network_interface) if (network_interface && strchr(network_interface, '.')) { if (strchr(network_interface, '/')) - { - char *ipaddr_cpy = Strdup(network_interface); - char *tok; + { + char *ipaddr_cpy = Strdup(network_interface); + char *tok; - tok = strtok(ipaddr_cpy, "/"); - if (!Inet_pton(AF_INET, tok, &addr_temp)) - cerebro_err_exit("network interface IP address '%s' invalid", + tok = strtok(ipaddr_cpy, "/"); + if (!Inet_pton(AF_INET, tok, &addr_temp)) + cerebro_err_exit("network interface IP address '%s' invalid", network_interface); - Free(ipaddr_cpy); - } + Free(ipaddr_cpy); + } else - { - if (!Inet_pton(AF_INET, network_interface, &addr_temp)) - cerebro_err_exit("network interface IP address '%s' invalid", + { + if (!Inet_pton(AF_INET, network_interface, &addr_temp)) + cerebro_err_exit("network interface IP address '%s' invalid", network_interface); - } + } } } @@ -1032,26 +1032,26 @@ _cerebrod_configuration_data_error_check(void) /* Check all interfaces */ for(ptr = buf; ptr < buf + ifc.ifc_len;) - { - struct sockaddr_in *sinptr; - int len; + { + struct sockaddr_in *sinptr; + int len; - ifr = (struct ifreq *)ptr; + ifr = (struct ifreq *)ptr; - len = _get_ifr_len(ifr); + len = _get_ifr_len(ifr); - ptr += sizeof(ifr->ifr_name) + len; + ptr += sizeof(ifr->ifr_name) + len; - sinptr = (struct sockaddr_in *)&ifr->ifr_addr; + sinptr = (struct sockaddr_in *)&ifr->ifr_addr; if (!memcmp((void *)&addr_temp, (void *)&sinptr->sin_addr, sizeof(struct in_addr))) { - found_interface++; - break; + found_interface++; + break; } - } + } Free(buf); Close(fd); @@ -1082,7 +1082,7 @@ _cerebrod_configuration_data_error_check(void) } if (conf.metric_server_port == conf.event_server_port) - cerebro_err_exit("metric server port '%d' cannot be identical " + cerebro_err_exit("metric server port '%d' cannot be identical " "to event server port", conf.metric_server_port); } diff --git a/src/cerebrod/cerebrod_daemon.c b/src/cerebrod/cerebrod_daemon.c index a74c2ffb..e13559c8 100644 --- a/src/cerebrod/cerebrod_daemon.c +++ b/src/cerebrod/cerebrod_daemon.c @@ -47,7 +47,7 @@ cerebrod_daemon_init(void) int i; pid = Fork(); - if (pid != 0) /* Terminate Parent */ + if (pid != 0) /* Terminate Parent */ exit(0); setsid(); @@ -55,7 +55,7 @@ cerebrod_daemon_init(void) Signal(SIGHUP, SIG_IGN); pid = Fork(); - if (pid != 0) /* Terminate 1st Child */ + if (pid != 0) /* Terminate 1st Child */ exit(0); Chdir("/"); diff --git a/src/cerebrod/cerebrod_debug.h b/src/cerebrod/cerebrod_debug.h index 9d18db31..16f488cf 100644 --- a/src/cerebrod/cerebrod_debug.h +++ b/src/cerebrod/cerebrod_debug.h @@ -43,7 +43,7 @@ #define CEREBROD_DBG(msg) \ do { \ if (conf.debug) \ - cerebro_err_debug msg; \ + cerebro_err_debug msg; \ } while(0) #endif /* !CEREBRO_DEBUG */ diff --git a/src/cerebrod/cerebrod_event_node_timeout_monitor.c b/src/cerebrod/cerebrod_event_node_timeout_monitor.c index 41819d22..39ee849c 100644 --- a/src/cerebrod/cerebrod_event_node_timeout_monitor.c +++ b/src/cerebrod/cerebrod_event_node_timeout_monitor.c @@ -268,7 +268,7 @@ cerebrod_event_node_timeout_monitor(void *arg) } - return NULL; /* NOT REACHED */ + return NULL; /* NOT REACHED */ } #endif /* !WITH_CEREBROD_SPEAKER_ONLY */ diff --git a/src/cerebrod/cerebrod_event_server.c b/src/cerebrod/cerebrod_event_server.c index 27647de2..601f18ee 100644 --- a/src/cerebrod/cerebrod_event_server.c +++ b/src/cerebrod/cerebrod_event_server.c @@ -381,7 +381,7 @@ cerebrod_event_queue_monitor(void *arg) List_destroy(temp_event_queue); - return NULL; /* NOT REACHED */ + return NULL; /* NOT REACHED */ } /* @@ -1222,7 +1222,7 @@ cerebrod_event_server(void *arg) Free(pfds); } - return NULL; /* NOT REACHED */ + return NULL; /* NOT REACHED */ } #endif /* !WITH_CEREBROD_SPEAKER_ONLY */ diff --git a/src/cerebrod/cerebrod_event_update.c b/src/cerebrod/cerebrod_event_update.c index 69e004c4..4794bd4b 100644 --- a/src/cerebrod/cerebrod_event_update.c +++ b/src/cerebrod/cerebrod_event_update.c @@ -439,9 +439,9 @@ cerebrod_event_modules_setup(void) event_module_timeouts = List_create((ListDelF)_cerebrod_event_module_timeout_data_destroy); event_module_timeout_index = Hash_create(event_module_count, - (hash_key_f)hash_key_string, - (hash_cmp_f)strcmp, - (hash_del_f)list_destroy); + (hash_key_f)hash_key_string, + (hash_cmp_f)strcmp, + (hash_del_f)list_destroy); for (i = 0; i < event_module_count; i++) { @@ -754,9 +754,9 @@ cerebrod_event_modules_update(const char *nodename, Pthread_mutex_unlock(&(el->event_list_lock)); while ((event_module = list_next(itr))) - { - Pthread_mutex_lock(&event_module->event_lock); - if ((rv = event_module_metric_update(event_handle, + { + Pthread_mutex_lock(&event_module->event_lock); + if ((rv = event_module_metric_update(event_handle, event_module->index, nodename, metric_name, @@ -773,8 +773,8 @@ cerebrod_event_modules_update(const char *nodename, cerebrod_queue_event(event, event_module->index); loop_next: - Pthread_mutex_unlock(&event_module->event_lock); - } + Pthread_mutex_unlock(&event_module->event_lock); + } Pthread_mutex_lock(&(el->event_list_lock)); List_iterator_destroy(itr); diff --git a/src/cerebrod/cerebrod_listener.c b/src/cerebrod/cerebrod_listener.c index 97a0e913..78e8c5af 100644 --- a/src/cerebrod/cerebrod_listener.c +++ b/src/cerebrod/cerebrod_listener.c @@ -150,10 +150,10 @@ _listener_setup_socket(int num) optlen = sizeof(struct ip_mreqn); if (setsockopt(fd, SOL_IP, IP_ADD_MEMBERSHIP, &imr, optlen) < 0) - { - CEREBROD_ERR(("setsockopt: %s", strerror(errno))); + { + CEREBROD_ERR(("setsockopt: %s", strerror(errno))); goto cleanup; - } + } } /* For quick start/restart */ @@ -625,23 +625,23 @@ cerebrod_listener(void *arg) /* No packet read */ if (recv_len <= 0) - continue; + continue; if (recv_len >= CEREBRO_MAX_PACKET_LEN) { - CEREBROD_DBG(("received truncated packet")); + CEREBROD_DBG(("received truncated packet")); continue; } if (_cerebrod_message_check_version(buf, recv_len) < 0) { - CEREBROD_DBG(("received invalid version packet")); + CEREBROD_DBG(("received invalid version packet")); continue; } if (!(msg = _cerebrod_message_unmarshall(buf, recv_len))) { - CEREBROD_DBG(("received unmarshallable packet")); + CEREBROD_DBG(("received unmarshallable packet")); continue; } @@ -679,11 +679,11 @@ cerebrod_listener(void *arg) in_cluster_flag = 1; if (!in_cluster_flag) - { - CEREBROD_DBG(("received non-cluster packet: %s", nodename_buf)); + { + CEREBROD_DBG(("received non-cluster packet: %s", nodename_buf)); cerebrod_message_destroy(msg); - continue; - } + continue; + } memset(nodename_key, '\0', CEREBRO_MAX_NODENAME_LEN+1); @@ -760,7 +760,7 @@ cerebrod_listener(void *arg) cerebrod_message_destroy(msg); } - return NULL; /* NOT REACHED */ + return NULL; /* NOT REACHED */ } #endif /* !WITH_CEREBROD_SPEAKER_ONLY */ diff --git a/src/cerebrod/cerebrod_listener_data.c b/src/cerebrod/cerebrod_listener_data.c index 55a079ba..54692094 100644 --- a/src/cerebrod/cerebrod_listener_data.c +++ b/src/cerebrod/cerebrod_listener_data.c @@ -574,11 +574,11 @@ _metric_data_update(struct cerebrod_node_data *nd, { /* Re-hash if our hash is getting too small */ if ((nd->metric_data_count + 1) > (nd->metric_data_size*2)) - cerebrod_rehash(&nd->metric_data, - &nd->metric_data_size, - LISTENER_DATA_METRIC_DATA_INCREMENT, - nd->metric_data_count, - &nd->node_data_lock); + cerebrod_rehash(&nd->metric_data, + &nd->metric_data_size, + LISTENER_DATA_METRIC_DATA_INCREMENT, + nd->metric_data_count, + &nd->node_data_lock); md = metric_data_create(metric_name); Hash_insert(nd->metric_data, md->metric_name, md); @@ -630,11 +630,11 @@ cerebrod_listener_data_update(char *nodename, { /* Re-hash if our hash is getting too small */ if ((listener_data_numnodes + 1) > (listener_data_size*2)) - cerebrod_rehash(&listener_data, - &listener_data_size, - LISTENER_DATA_SIZE_INCREMENT, - listener_data_numnodes, - &listener_data_lock); + cerebrod_rehash(&listener_data, + &listener_data_size, + LISTENER_DATA_SIZE_INCREMENT, + listener_data_numnodes, + &listener_data_lock); nd = _cerebrod_node_data_create_and_init(nodename); Hash_insert(listener_data, nd->nodename, nd); diff --git a/src/cerebrod/cerebrod_metric_controller.c b/src/cerebrod/cerebrod_metric_controller.c index 92b56385..e6434a2b 100644 --- a/src/cerebrod/cerebrod_metric_controller.c +++ b/src/cerebrod/cerebrod_metric_controller.c @@ -1133,7 +1133,7 @@ cerebrod_metric_controller(void *arg) Pthread_attr_destroy(&attr); } - return NULL; /* NOT REACHED */ + return NULL; /* NOT REACHED */ } #endif /* !WITH_CEREBROD_SPEAKER_ONLY */ diff --git a/src/cerebrod/cerebrod_metric_server.c b/src/cerebrod/cerebrod_metric_server.c index ef616b46..6b7a8d44 100644 --- a/src/cerebrod/cerebrod_metric_server.c +++ b/src/cerebrod/cerebrod_metric_server.c @@ -326,7 +326,7 @@ _metric_server_respond_with_error(int fd, int32_t version, u_int32_t err_code) assert(fd >= 0 && err_code >= CEREBRO_METRIC_SERVER_PROTOCOL_ERR_VERSION_INVALID - && err_code <= CEREBRO_METRIC_SERVER_PROTOCOL_ERR_INTERNAL_ERROR); + && err_code <= CEREBRO_METRIC_SERVER_PROTOCOL_ERR_INTERNAL_ERROR); memset(&res, '\0', CEREBRO_METRIC_SERVER_ERR_RESPONSE_LEN); res.version = version; @@ -1034,7 +1034,7 @@ cerebrod_metric_server(void *arg) Pthread_attr_destroy(&attr); } - return NULL; /* NOT REACHED */ + return NULL; /* NOT REACHED */ } #endif /* !WITH_CEREBROD_SPEAKER_ONLY */ diff --git a/src/cerebrod/cerebrod_monitor_update.c b/src/cerebrod/cerebrod_monitor_update.c index 8db738b4..a694c219 100644 --- a/src/cerebrod/cerebrod_monitor_update.c +++ b/src/cerebrod/cerebrod_monitor_update.c @@ -316,17 +316,17 @@ cerebrod_monitor_modules_update(const char *nodename, Pthread_mutex_unlock(&(ml->monitor_list_lock)); while ((monitor_module = list_next(itr))) - { - Pthread_mutex_lock(&monitor_module->monitor_lock); - monitor_module_metric_update(monitor_handle, - monitor_module->index, - nodename, - metric_name, - mm->metric_value_type, - mm->metric_value_len, - mm->metric_value); - Pthread_mutex_unlock(&monitor_module->monitor_lock); - } + { + Pthread_mutex_lock(&monitor_module->monitor_lock); + monitor_module_metric_update(monitor_handle, + monitor_module->index, + nodename, + metric_name, + mm->metric_value_type, + mm->metric_value_len, + mm->metric_value); + Pthread_mutex_unlock(&monitor_module->monitor_lock); + } Pthread_mutex_lock(&(ml->monitor_list_lock)); List_iterator_destroy(itr); diff --git a/src/cerebrod/cerebrod_speaker.c b/src/cerebrod/cerebrod_speaker.c index 213abfe2..cc449b94 100644 --- a/src/cerebrod/cerebrod_speaker.c +++ b/src/cerebrod/cerebrod_speaker.c @@ -128,35 +128,35 @@ _speaker_setup_socket(int num) memset(&imr, '\0', sizeof(struct ip_mreqn)); memcpy(&imr.imr_multiaddr, - &conf.speak_message_config[num].ip_in_addr, - sizeof(struct in_addr)); + &conf.speak_message_config[num].ip_in_addr, + sizeof(struct in_addr)); memcpy(&imr.imr_address, - &conf.speak_message_config[num].network_interface_in_addr, - sizeof(struct in_addr)); + &conf.speak_message_config[num].network_interface_in_addr, + sizeof(struct in_addr)); imr.imr_ifindex = conf.speak_message_config[num].network_interface_index; optlen = sizeof(struct ip_mreqn); if (setsockopt(fd, SOL_IP, IP_MULTICAST_IF, &imr, optlen) < 0) - { - CEREBROD_ERR(("setsockopt: %s", strerror(errno))); + { + CEREBROD_ERR(("setsockopt: %s", strerror(errno))); goto cleanup; - } + } optval = 1; optlen = sizeof(optval); if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &optval, optlen) < 0) - { - CEREBROD_ERR(("setsockopt: %s", strerror(errno))); + { + CEREBROD_ERR(("setsockopt: %s", strerror(errno))); goto cleanup; - } + } optval = conf.speak_message_ttl; optlen = sizeof(optval); if (setsockopt(fd, SOL_IP, IP_MULTICAST_TTL, &optval, optlen) < 0) - { - CEREBROD_ERR(("setsockopt: %s", strerror(errno))); + { + CEREBROD_ERR(("setsockopt: %s", strerror(errno))); goto cleanup; - } + } } /* For quick start/restart */ @@ -172,8 +172,8 @@ _speaker_setup_socket(int num) addr.sin_family = AF_INET; addr.sin_port = htons(conf.speak_message_config[num].source_port); memcpy(&addr.sin_addr, - &conf.speak_message_config[num].network_interface_in_addr, - sizeof(struct in_addr)); + &conf.speak_message_config[num].network_interface_in_addr, + sizeof(struct in_addr)); if (bind(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) < 0) { CEREBROD_ERR(("bind: %s", strerror(errno))); @@ -515,9 +515,9 @@ cerebrod_speaker(void *arg) time_t now; if (conf.gettimeofday_workaround) - Gettimeofday_workaround(&tv, NULL); + Gettimeofday_workaround(&tv, NULL); else - Gettimeofday(&tv, NULL); + Gettimeofday(&tv, NULL); now = tv.tv_sec; /* Note: After initial setup, we are the only thread that uses this @@ -578,43 +578,43 @@ cerebrod_speaker(void *arg) else t = conf.heartbeat_frequency_min; - if (conf.gettimeofday_workaround) - { - /* On a number of Intel systems, it has been - * observed that gettimeofday can occasionally - * return erroneous values. For example, values 40 - * years into the future. Then it goes back to - * returning valid values. - * - * Even the present workaround in Gettimeofday() was - * not found to be sufficient, so this additional - * workaround has been put in place. - * - * The following code should work around this - * situation. - */ - if (conf.heartbeat_frequency_ranged - && nst->next_send_time - && (((now + t) - nst->next_send_time) > (2 * conf.heartbeat_frequency_max))) - { - if (((now + t) - nst->next_send_time) < (10 * conf.heartbeat_frequency_max)) - { - /* If the tv_sec is only moderately off, assume it's due to drift and it's ok */ - nst->next_send_time = now + t; - } - else - { - CEREBROD_ERR (("Forcing maximum heartbeat frequency due to out of range time. " + if (conf.gettimeofday_workaround) + { + /* On a number of Intel systems, it has been + * observed that gettimeofday can occasionally + * return erroneous values. For example, values 40 + * years into the future. Then it goes back to + * returning valid values. + * + * Even the present workaround in Gettimeofday() was + * not found to be sufficient, so this additional + * workaround has been put in place. + * + * The following code should work around this + * situation. + */ + if (conf.heartbeat_frequency_ranged + && nst->next_send_time + && (((now + t) - nst->next_send_time) > (2 * conf.heartbeat_frequency_max))) + { + if (((now + t) - nst->next_send_time) < (10 * conf.heartbeat_frequency_max)) + { + /* If the tv_sec is only moderately off, assume it's due to drift and it's ok */ + nst->next_send_time = now + t; + } + else + { + CEREBROD_ERR (("Forcing maximum heartbeat frequency due to out of range time. " "tv_sec:%lu, t:%d, next_send_time:%u", now, t, (unsigned)nst->next_send_time)); - nst->next_send_time = now + conf.heartbeat_frequency_max; - } - } - else - nst->next_send_time = now + t; - } - else - nst->next_send_time = now + t; + nst->next_send_time = now + conf.heartbeat_frequency_max; + } + } + else + nst->next_send_time = now + t; + } + else + nst->next_send_time = now + t; } if (nst->next_send_type & CEREBROD_SPEAKER_NEXT_SEND_TYPE_MODULE) nst->next_send_time = now + nst->metric_period; @@ -628,21 +628,21 @@ cerebrod_speaker(void *arg) nst = List_peek(next_send_times); if (conf.gettimeofday_workaround) - { - if ((nst->next_send_type & CEREBROD_SPEAKER_NEXT_SEND_TYPE_HEARTBEAT) - && (((nst->next_send_time - now) < 0) - || (conf.heartbeat_frequency_ranged - && ((nst->next_send_time - now) > conf.heartbeat_frequency_max)))) - sleep_time = conf.heartbeat_frequency_max; - else - sleep_time = nst->next_send_time - now; - } + { + if ((nst->next_send_type & CEREBROD_SPEAKER_NEXT_SEND_TYPE_HEARTBEAT) + && (((nst->next_send_time - now) < 0) + || (conf.heartbeat_frequency_ranged + && ((nst->next_send_time - now) > conf.heartbeat_frequency_max)))) + sleep_time = conf.heartbeat_frequency_max; + else + sleep_time = nst->next_send_time - now; + } else - sleep_time = nst->next_send_time - now; + sleep_time = nst->next_send_time - now; sleep(sleep_time); } - return NULL; /* NOT REACHED */ + return NULL; /* NOT REACHED */ } int @@ -660,11 +660,11 @@ cerebrod_send_message(struct cerebrod_message *msg) for (i = 0; i < msg->metrics_len; i++) { if (!msg->metrics[i]) - { - CEREBROD_DBG(("null metrics pointer")); - errno = EINVAL; - goto cleanup; - } + { + CEREBROD_DBG(("null metrics pointer")); + errno = EINVAL; + goto cleanup; + } msglen += CEREBROD_MESSAGE_METRIC_HEADER_LEN; msglen += msg->metrics[i]->metric_value_len; } diff --git a/src/cerebrod/cerebrod_speaker_data.c b/src/cerebrod/cerebrod_speaker_data.c index 9e448621..4f74b1df 100644 --- a/src/cerebrod/cerebrod_speaker_data.c +++ b/src/cerebrod/cerebrod_speaker_data.c @@ -617,7 +617,7 @@ cerebrod_speaker_data_get_heartbeat_metric_data(struct cerebrod_message *msg, if (metric_info->metric_origin & CEREBROD_METRIC_SPEAKER_ORIGIN_MODULE && !(metric_info->metric_flags & CEREBRO_METRIC_MODULE_FLAGS_SEND_ON_PERIOD)) - mm = _get_module_metric_value(metric_info->index); + mm = _get_module_metric_value(metric_info->index); if (metric_info->metric_origin & CEREBROD_METRIC_SPEAKER_ORIGIN_USERSPACE) mm = _get_userspace_metric_value(metric_info); diff --git a/src/cerebrod/cerebrod_util.c b/src/cerebrod/cerebrod_util.c index 3cf140b1..34982817 100644 --- a/src/cerebrod/cerebrod_util.c +++ b/src/cerebrod/cerebrod_util.c @@ -83,10 +83,10 @@ _hash_removeall(void *data, const void *key, void *arg) void cerebrod_rehash(hash_t *old_hash, - int *hash_size, - int hash_size_increment, - int hash_num, - pthread_mutex_t *hash_mutex) + int *hash_size, + int hash_size_increment, + int hash_num, + pthread_mutex_t *hash_mutex) { hash_t new_hash; @@ -105,9 +105,9 @@ cerebrod_rehash(hash_t *old_hash, *hash_size += hash_size_increment; new_hash = Hash_create(*hash_size, - (hash_key_f)hash_key_string, - (hash_cmp_f)strcmp, - (hash_del_f)_Free); + (hash_key_f)hash_key_string, + (hash_cmp_f)strcmp, + (hash_del_f)_Free); if (Hash_for_each(*old_hash, _hash_reinsert, &new_hash) != hash_num) CEREBROD_EXIT(("invalid reinsert: hash_num=%d", hash_num)); diff --git a/src/libs/cerebro/cerebro.c b/src/libs/cerebro/cerebro.c index 9ca3d7d4..e41b2251 100644 --- a/src/libs/cerebro/cerebro.c +++ b/src/libs/cerebro/cerebro.c @@ -126,7 +126,7 @@ cerebro_handle_destroy(cerebro_t handle) if (handle->loaded_state & CEREBRO_CONFIG_LOADED) { if (_cerebro_unload_config(handle) < 0) - return -1; + return -1; if (handle->loaded_state & CEREBRO_CONFIG_LOADED) { diff --git a/src/libs/cerebro/cerebro_nodelist_util.c b/src/libs/cerebro/cerebro_nodelist_util.c index 95886df7..a3989f79 100644 --- a/src/libs/cerebro/cerebro_nodelist_util.c +++ b/src/libs/cerebro/cerebro_nodelist_util.c @@ -140,7 +140,7 @@ _cerebro_nodelist_create(cerebro_t handle, const char *metric_name) int _cerebro_nodelist_append(cerebro_nodelist_t nodelist, - const char *nodename, + const char *nodename, u_int32_t metric_value_received_time, u_int32_t metric_value_type, u_int32_t metric_value_len, diff --git a/src/libs/cerebro/cerebro_nodelist_util.h b/src/libs/cerebro/cerebro_nodelist_util.h index 7da1f837..0a55020b 100644 --- a/src/libs/cerebro/cerebro_nodelist_util.h +++ b/src/libs/cerebro/cerebro_nodelist_util.h @@ -58,7 +58,7 @@ cerebro_nodelist_t _cerebro_nodelist_create(cerebro_t handle, * Returns 0 on success, -1 on error */ int _cerebro_nodelist_append(cerebro_nodelist_t nodelist, - const char *nodename, + const char *nodename, u_int32_t metric_value_received_time, u_int32_t metric_value_type, u_int32_t metric_value_len, diff --git a/src/libs/include/cerebro.h b/src/libs/include/cerebro.h index 331bfd69..d466c7d9 100644 --- a/src/libs/include/cerebro.h +++ b/src/libs/include/cerebro.h @@ -338,7 +338,7 @@ cerebro_namelist_t cerebro_get_metric_names(cerebro_t handle); * Returns nodelist on success, -1 on error */ cerebro_nodelist_t cerebro_get_metric_data(cerebro_t handle, - const char *metric_name); + const char *metric_name); /* * Metric Monitoring API @@ -370,7 +370,7 @@ int cerebro_unregister_metric(cerebro_t handle, const char *metric_name); * Returns 0 on success, -1 on error */ int cerebro_update_metric_value(cerebro_t handle, - const char *metric_name, + const char *metric_name, unsigned int metric_value_type, unsigned int metric_value_len, void *metric_value); diff --git a/src/libs/modules/clusterlist_module.c b/src/libs/modules/clusterlist_module.c index 01bb9e15..18e6258b 100644 --- a/src/libs/modules/clusterlist_module.c +++ b/src/libs/modules/clusterlist_module.c @@ -382,9 +382,9 @@ clusterlist_module_node_in_cluster(clusterlist_module_t handle, const char *node int clusterlist_module_get_nodename(clusterlist_module_t handle, - const char *node, - char *buf, - unsigned int buflen) + const char *node, + char *buf, + unsigned int buflen) { if (_handle_info_check(handle) < 0) return -1; diff --git a/src/libs/modules/clusterlist_module.h b/src/libs/modules/clusterlist_module.h index 76373d5d..ccd6525e 100644 --- a/src/libs/modules/clusterlist_module.h +++ b/src/libs/modules/clusterlist_module.h @@ -112,8 +112,8 @@ int clusterlist_module_node_in_cluster(clusterlist_module_t handle, * call clusterlist module get nodename function */ int clusterlist_module_get_nodename(clusterlist_module_t handle, - const char *node, - char *buf, - unsigned int buflen); + const char *node, + char *buf, + unsigned int buflen); #endif /* _CLUSTERLIST_MODULE_H */ diff --git a/src/libs/modules/config_module.h b/src/libs/modules/config_module.h index 1959190f..05bc7a30 100644 --- a/src/libs/modules/config_module.h +++ b/src/libs/modules/config_module.h @@ -92,7 +92,7 @@ int config_module_cleanup(config_module_t handle); * call config module get all nodes function */ int config_module_load_config(config_module_t handle, - struct cerebro_config *conf); + struct cerebro_config *conf); #endif /* _CONFIG_MODULE_H */ diff --git a/src/libs/modules/metric_module.c b/src/libs/modules/metric_module.c index de311b3c..2f6fcdcc 100644 --- a/src/libs/modules/metric_module.c +++ b/src/libs/modules/metric_module.c @@ -514,10 +514,10 @@ metric_module_get_metric_flags(metric_modules_t handle, int metric_module_get_metric_value(metric_modules_t handle, - unsigned int index, - unsigned int *metric_value_type, - unsigned int *metric_value_len, - void **metric_value) + unsigned int index, + unsigned int *metric_value_type, + unsigned int *metric_value_len, + void **metric_value) { struct cerebro_metric_module_info *module_info; @@ -537,8 +537,8 @@ metric_module_get_metric_value(metric_modules_t handle, int metric_module_destroy_metric_value(metric_modules_t handle, - unsigned int index, - void *metric_value) + unsigned int index, + void *metric_value) { struct cerebro_metric_module_info *module_info; diff --git a/src/libs/modules/metric_module.h b/src/libs/modules/metric_module.h index 1e41b4a6..b8a5f6a6 100644 --- a/src/libs/modules/metric_module.h +++ b/src/libs/modules/metric_module.h @@ -114,10 +114,10 @@ int metric_module_get_metric_flags(metric_modules_t handle, * call metric module get_metric_value function */ int metric_module_get_metric_value(metric_modules_t handle, - unsigned int index, - unsigned int *metric_value_type, - unsigned int *metric_value_len, - void **metric_value); + unsigned int index, + unsigned int *metric_value_type, + unsigned int *metric_value_len, + void **metric_value); /* * metric_module_destroy_metric_value @@ -125,8 +125,8 @@ int metric_module_get_metric_value(metric_modules_t handle, * call metric module destroy_metric_value function */ int metric_module_destroy_metric_value(metric_modules_t handle, - unsigned int index, - void *metric_value); + unsigned int index, + void *metric_value); /* * metric_module_get_metric_thread diff --git a/src/libs/modules/monitor_module.c b/src/libs/modules/monitor_module.c index 7a43655e..e5a79bee 100644 --- a/src/libs/modules/monitor_module.c +++ b/src/libs/modules/monitor_module.c @@ -415,12 +415,12 @@ monitor_module_metric_names(monitor_modules_t handle, unsigned int index) int monitor_module_metric_update(monitor_modules_t handle, - unsigned int index, - const char *nodename, + unsigned int index, + const char *nodename, const char *metric_name, - unsigned int metric_value_type, - unsigned int metric_value_len, - void *metric_value) + unsigned int metric_value_type, + unsigned int metric_value_len, + void *metric_value) { struct cerebro_monitor_module_info *module_info; diff --git a/src/libs/modules/monitor_module.h b/src/libs/modules/monitor_module.h index 59715c02..a126bb13 100644 --- a/src/libs/modules/monitor_module.h +++ b/src/libs/modules/monitor_module.h @@ -96,11 +96,11 @@ char *monitor_module_metric_names(monitor_modules_t handle, unsigned int index); * call monitor module metric_update function */ int monitor_module_metric_update(monitor_modules_t handle, - unsigned int index, - const char *nodename, + unsigned int index, + const char *nodename, const char *metric_name, - unsigned int metric_value_type, - unsigned int metric_value_len, - void *metric_value); + unsigned int metric_value_type, + unsigned int metric_value_len, + void *metric_value); #endif /* _MONITOR_MODULE_H */ diff --git a/src/libs/util/config_util.c b/src/libs/util/config_util.c index 785ec920..20ed0736 100644 --- a/src/libs/util/config_util.c +++ b/src/libs/util/config_util.c @@ -120,8 +120,8 @@ _load_config_module(struct cerebro_config *conf, unsigned int *errnum) */ static int _cb_cerebrod_heartbeat_freq(conffile_t cf, struct conffile_data *data, - char *optionname, int option_type, void *option_ptr, - int option_data, void *app_ptr, int app_data) + char *optionname, int option_type, void *option_ptr, + int option_data, void *app_ptr, int app_data) { struct cerebro_config *conf; @@ -642,8 +642,8 @@ _cb_cerebrod_forward_host_accept(conffile_t cf, struct conffile_data *data, */ static int _cb_cerebrod_module_exclude(conffile_t cf, struct conffile_data *data, - char *optionname, int option_type, void *option_ptr, - int option_data, void *app_ptr, int app_data) + char *optionname, int option_type, void *option_ptr, + int option_data, void *app_ptr, int app_data) { struct cerebro_config *conf; @@ -667,43 +667,43 @@ _cb_cerebrod_module_exclude(conffile_t cf, struct conffile_data *data, return -1; } - /* achu: passing char[][] as pointer is badness, play it safe */ - if (!strcasecmp(optionname, "cerebrod_metric_module_exclude")) - { - if (conf->cerebrod_metric_module_exclude_len >= CEREBRO_CONFIG_METRIC_MODULE_EXCLUDE_MAX) - { - conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_TOOMANY); - return -1; - } - - strcpy(conf->cerebrod_metric_module_exclude[conf->cerebrod_metric_module_exclude_len], - data->stringlist[i]); - conf->cerebrod_metric_module_exclude_len++; - } - else if (!strcasecmp(optionname, "cerebrod_monitor_module_exclude")) - { - if (conf->cerebrod_monitor_module_exclude_len >= CEREBRO_CONFIG_MONITOR_MODULE_EXCLUDE_MAX) - { - conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_TOOMANY); - return -1; - } - - strcpy(conf->cerebrod_monitor_module_exclude[conf->cerebrod_monitor_module_exclude_len], - data->stringlist[i]); - conf->cerebrod_monitor_module_exclude_len++; - } - else if (!strcasecmp(optionname, "cerebrod_event_module_exclude")) - { - if (conf->cerebrod_event_module_exclude_len >= CEREBRO_CONFIG_EVENT_MODULE_EXCLUDE_MAX) - { - conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_TOOMANY); - return -1; - } - - strcpy(conf->cerebrod_event_module_exclude[conf->cerebrod_event_module_exclude_len], - data->stringlist[i]); - conf->cerebrod_event_module_exclude_len++; - } + /* achu: passing char[][] as pointer is badness, play it safe */ + if (!strcasecmp(optionname, "cerebrod_metric_module_exclude")) + { + if (conf->cerebrod_metric_module_exclude_len >= CEREBRO_CONFIG_METRIC_MODULE_EXCLUDE_MAX) + { + conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_TOOMANY); + return -1; + } + + strcpy(conf->cerebrod_metric_module_exclude[conf->cerebrod_metric_module_exclude_len], + data->stringlist[i]); + conf->cerebrod_metric_module_exclude_len++; + } + else if (!strcasecmp(optionname, "cerebrod_monitor_module_exclude")) + { + if (conf->cerebrod_monitor_module_exclude_len >= CEREBRO_CONFIG_MONITOR_MODULE_EXCLUDE_MAX) + { + conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_TOOMANY); + return -1; + } + + strcpy(conf->cerebrod_monitor_module_exclude[conf->cerebrod_monitor_module_exclude_len], + data->stringlist[i]); + conf->cerebrod_monitor_module_exclude_len++; + } + else if (!strcasecmp(optionname, "cerebrod_event_module_exclude")) + { + if (conf->cerebrod_event_module_exclude_len >= CEREBRO_CONFIG_EVENT_MODULE_EXCLUDE_MAX) + { + conffile_seterrnum(cf, CONFFILE_ERR_PARSE_ARG_TOOMANY); + return -1; + } + + strcpy(conf->cerebrod_event_module_exclude[conf->cerebrod_event_module_exclude_len], + data->stringlist[i]); + conf->cerebrod_event_module_exclude_len++; + } } } return 0; @@ -788,305 +788,305 @@ _load_config_file(struct cerebro_config *conf, unsigned int *errnum) 0 }, { - "cerebro_timeout_len", - CONFFILE_OPTION_INT, - -1, - conffile_int, - 1, - 0, - &(conf->cerebro_timeout_len_flag), - &(conf->cerebro_timeout_len), - 0 + "cerebro_timeout_len", + CONFFILE_OPTION_INT, + -1, + conffile_int, + 1, + 0, + &(conf->cerebro_timeout_len_flag), + &(conf->cerebro_timeout_len), + 0 }, { - "cerebro_flags", - CONFFILE_OPTION_INT, - -1, - conffile_int, - 1, - 0, - &(conf->cerebro_flags_flag), - &(conf->cerebro_flags), - 0 + "cerebro_flags", + CONFFILE_OPTION_INT, + -1, + conffile_int, + 1, + 0, + &(conf->cerebro_flags_flag), + &(conf->cerebro_flags), + 0 }, /* * Cerebrod configuration */ { - "cerebrod_heartbeat_frequency", - CONFFILE_OPTION_LIST_INT, - -1, - _cb_cerebrod_heartbeat_freq, - 1, - 0, - &(conf->cerebrod_heartbeat_frequency_flag), - conf, - 0 + "cerebrod_heartbeat_frequency", + CONFFILE_OPTION_LIST_INT, + -1, + _cb_cerebrod_heartbeat_freq, + 1, + 0, + &(conf->cerebrod_heartbeat_frequency_flag), + conf, + 0 }, { - "cerebrod_speak", - CONFFILE_OPTION_BOOL, - -1, - conffile_bool, - 1, - 0, - &(conf->cerebrod_speak_flag), - &conf->cerebrod_speak, - 0 + "cerebrod_speak", + CONFFILE_OPTION_BOOL, + -1, + conffile_bool, + 1, + 0, + &(conf->cerebrod_speak_flag), + &conf->cerebrod_speak, + 0 }, { - "cerebrod_speak_message_config", - CONFFILE_OPTION_LIST_STRING, - -1, - _cb_cerebrod_speak_message_config, - CEREBRO_CONFIG_SPEAK_MESSAGE_CONFIG_MAX, - 0, - &(conf->cerebrod_speak_message_config_flag), - conf, - 0 + "cerebrod_speak_message_config", + CONFFILE_OPTION_LIST_STRING, + -1, + _cb_cerebrod_speak_message_config, + CEREBRO_CONFIG_SPEAK_MESSAGE_CONFIG_MAX, + 0, + &(conf->cerebrod_speak_message_config_flag), + conf, + 0 }, { - "cerebrod_speak_message_ttl", - CONFFILE_OPTION_INT, - -1, - conffile_int, - 1, - 0, - &(conf->cerebrod_speak_message_ttl_flag), - &(conf->cerebrod_speak_message_ttl), - 0 + "cerebrod_speak_message_ttl", + CONFFILE_OPTION_INT, + -1, + conffile_int, + 1, + 0, + &(conf->cerebrod_speak_message_ttl_flag), + &(conf->cerebrod_speak_message_ttl), + 0 }, { - "cerebrod_listen", - CONFFILE_OPTION_BOOL, - -1, - conffile_bool, - 1, - 0, - &(conf->cerebrod_listen_flag), - &conf->cerebrod_listen, - 0 + "cerebrod_listen", + CONFFILE_OPTION_BOOL, + -1, + conffile_bool, + 1, + 0, + &(conf->cerebrod_listen_flag), + &conf->cerebrod_listen, + 0 }, { - "cerebrod_listen_threads", - CONFFILE_OPTION_INT, - -1, - conffile_int, - 1, - 0, - &(conf->cerebrod_listen_threads_flag), - &(conf->cerebrod_listen_threads), - 0 + "cerebrod_listen_threads", + CONFFILE_OPTION_INT, + -1, + conffile_int, + 1, + 0, + &(conf->cerebrod_listen_threads_flag), + &(conf->cerebrod_listen_threads), + 0 }, { - "cerebrod_listen_message_config", - CONFFILE_OPTION_LIST_STRING, - -1, - _cb_cerebrod_listen_message_config, - CEREBRO_CONFIG_LISTEN_MESSAGE_CONFIG_MAX, - 0, - &(conf->cerebrod_listen_message_config_flag), - conf, - 0 + "cerebrod_listen_message_config", + CONFFILE_OPTION_LIST_STRING, + -1, + _cb_cerebrod_listen_message_config, + CEREBRO_CONFIG_LISTEN_MESSAGE_CONFIG_MAX, + 0, + &(conf->cerebrod_listen_message_config_flag), + conf, + 0 }, { - "cerebrod_metric_controller", - CONFFILE_OPTION_BOOL, - -1, - conffile_bool, - 1, - 0, - &(conf->cerebrod_metric_controller_flag), - &conf->cerebrod_metric_controller, - 0 + "cerebrod_metric_controller", + CONFFILE_OPTION_BOOL, + -1, + conffile_bool, + 1, + 0, + &(conf->cerebrod_metric_controller_flag), + &conf->cerebrod_metric_controller, + 0 }, { - "cerebrod_metric_server", - CONFFILE_OPTION_BOOL, - -1, - conffile_bool, - 1, - 0, - &(conf->cerebrod_metric_server_flag), - &conf->cerebrod_metric_server, - 0 + "cerebrod_metric_server", + CONFFILE_OPTION_BOOL, + -1, + conffile_bool, + 1, + 0, + &(conf->cerebrod_metric_server_flag), + &conf->cerebrod_metric_server, + 0 }, { - "cerebrod_metric_server_port", - CONFFILE_OPTION_INT, - -1, - conffile_int, - 1, - 0, - &(conf->cerebrod_metric_server_port_flag), - &(conf->cerebrod_metric_server_port), - 0 + "cerebrod_metric_server_port", + CONFFILE_OPTION_INT, + -1, + conffile_int, + 1, + 0, + &(conf->cerebrod_metric_server_port_flag), + &(conf->cerebrod_metric_server_port), + 0 }, { - "cerebrod_event_server", - CONFFILE_OPTION_BOOL, - -1, - conffile_bool, - 1, - 0, - &(conf->cerebrod_event_server_flag), - &conf->cerebrod_event_server, - 0 + "cerebrod_event_server", + CONFFILE_OPTION_BOOL, + -1, + conffile_bool, + 1, + 0, + &(conf->cerebrod_event_server_flag), + &conf->cerebrod_event_server, + 0 }, { - "cerebrod_event_server_port", - CONFFILE_OPTION_INT, - -1, - conffile_int, - 1, - 0, - &(conf->cerebrod_event_server_port_flag), - &(conf->cerebrod_event_server_port), - 0 + "cerebrod_event_server_port", + CONFFILE_OPTION_INT, + -1, + conffile_int, + 1, + 0, + &(conf->cerebrod_event_server_port_flag), + &(conf->cerebrod_event_server_port), + 0 }, { - "cerebrod_forward_message_config", - CONFFILE_OPTION_LIST_STRING, - -1, - _cb_cerebrod_forward_message_config, - CEREBRO_CONFIG_FORWARD_MESSAGE_CONFIG_MAX, - 0, - &(conf->cerebrod_forward_message_config_flag), - conf, - 0 + "cerebrod_forward_message_config", + CONFFILE_OPTION_LIST_STRING, + -1, + _cb_cerebrod_forward_message_config, + CEREBRO_CONFIG_FORWARD_MESSAGE_CONFIG_MAX, + 0, + &(conf->cerebrod_forward_message_config_flag), + conf, + 0 }, { - "cerebrod_forward_message_ttl", - CONFFILE_OPTION_INT, - -1, - conffile_int, - 1, - 0, - &(conf->cerebrod_forward_message_ttl_flag), - &(conf->cerebrod_forward_message_ttl), - 0 + "cerebrod_forward_message_ttl", + CONFFILE_OPTION_INT, + -1, + conffile_int, + 1, + 0, + &(conf->cerebrod_forward_message_ttl_flag), + &(conf->cerebrod_forward_message_ttl), + 0 }, { - "cerebrod_forward_host_accept", - CONFFILE_OPTION_LIST_STRING, - -1, - _cb_cerebrod_forward_host_accept, - CEREBRO_CONFIG_FORWARD_HOST_ACCEPT_MAX, - 0, - &(conf->cerebrod_forward_host_accept_flag), - conf, - 0 + "cerebrod_forward_host_accept", + CONFFILE_OPTION_LIST_STRING, + -1, + _cb_cerebrod_forward_host_accept, + CEREBRO_CONFIG_FORWARD_HOST_ACCEPT_MAX, + 0, + &(conf->cerebrod_forward_host_accept_flag), + conf, + 0 }, { - "cerebrod_metric_module_exclude", - CONFFILE_OPTION_LIST_STRING, - -1, - _cb_cerebrod_module_exclude, - CEREBRO_CONFIG_METRIC_MODULE_EXCLUDE_MAX, - 0, - &(conf->cerebrod_metric_module_exclude_flag), - conf, - 0 + "cerebrod_metric_module_exclude", + CONFFILE_OPTION_LIST_STRING, + -1, + _cb_cerebrod_module_exclude, + CEREBRO_CONFIG_METRIC_MODULE_EXCLUDE_MAX, + 0, + &(conf->cerebrod_metric_module_exclude_flag), + conf, + 0 }, { - "cerebrod_monitor_module_exclude", - CONFFILE_OPTION_LIST_STRING, - -1, - _cb_cerebrod_module_exclude, - CEREBRO_CONFIG_MONITOR_MODULE_EXCLUDE_MAX, - 0, - &(conf->cerebrod_monitor_module_exclude_flag), - conf, - 0 + "cerebrod_monitor_module_exclude", + CONFFILE_OPTION_LIST_STRING, + -1, + _cb_cerebrod_module_exclude, + CEREBRO_CONFIG_MONITOR_MODULE_EXCLUDE_MAX, + 0, + &(conf->cerebrod_monitor_module_exclude_flag), + conf, + 0 }, { - "cerebrod_event_module_exclude", - CONFFILE_OPTION_LIST_STRING, - -1, - _cb_cerebrod_module_exclude, - CEREBRO_CONFIG_EVENT_MODULE_EXCLUDE_MAX, - 0, - &(conf->cerebrod_event_module_exclude_flag), - conf, - 0 + "cerebrod_event_module_exclude", + CONFFILE_OPTION_LIST_STRING, + -1, + _cb_cerebrod_module_exclude, + CEREBRO_CONFIG_EVENT_MODULE_EXCLUDE_MAX, + 0, + &(conf->cerebrod_event_module_exclude_flag), + conf, + 0 }, { - "cerebrod_speak_debug", - CONFFILE_OPTION_BOOL, - -1, - conffile_bool, - 1, - 0, - &(conf->cerebrod_speak_debug_flag), - &conf->cerebrod_speak_debug, - 0 + "cerebrod_speak_debug", + CONFFILE_OPTION_BOOL, + -1, + conffile_bool, + 1, + 0, + &(conf->cerebrod_speak_debug_flag), + &conf->cerebrod_speak_debug, + 0 }, { - "cerebrod_listen_debug", - CONFFILE_OPTION_BOOL, - -1, - conffile_bool, - 1, - 0, - &(conf->cerebrod_listen_debug_flag), - &conf->cerebrod_listen_debug, - 0 + "cerebrod_listen_debug", + CONFFILE_OPTION_BOOL, + -1, + conffile_bool, + 1, + 0, + &(conf->cerebrod_listen_debug_flag), + &conf->cerebrod_listen_debug, + 0 }, { - "cerebrod_metric_controller_debug", - CONFFILE_OPTION_BOOL, - -1, - conffile_bool, - 1, - 0, - &(conf->cerebrod_metric_controller_debug_flag), - &conf->cerebrod_metric_controller_debug, - 0 + "cerebrod_metric_controller_debug", + CONFFILE_OPTION_BOOL, + -1, + conffile_bool, + 1, + 0, + &(conf->cerebrod_metric_controller_debug_flag), + &conf->cerebrod_metric_controller_debug, + 0 }, { - "cerebrod_metric_server_debug", - CONFFILE_OPTION_BOOL, - -1, - conffile_bool, - 1, - 0, - &(conf->cerebrod_metric_server_debug_flag), - &conf->cerebrod_metric_server_debug, - 0 + "cerebrod_metric_server_debug", + CONFFILE_OPTION_BOOL, + -1, + conffile_bool, + 1, + 0, + &(conf->cerebrod_metric_server_debug_flag), + &conf->cerebrod_metric_server_debug, + 0 }, { - "cerebrod_event_server_debug", - CONFFILE_OPTION_BOOL, - -1, - conffile_bool, - 1, - 0, - &(conf->cerebrod_event_server_debug_flag), - &conf->cerebrod_event_server_debug, - 0 + "cerebrod_event_server_debug", + CONFFILE_OPTION_BOOL, + -1, + conffile_bool, + 1, + 0, + &(conf->cerebrod_event_server_debug_flag), + &conf->cerebrod_event_server_debug, + 0 }, { - "cerebrod_gettimeofday_workaround", - CONFFILE_OPTION_BOOL, - -1, - conffile_bool, - 1, - 0, - &(conf->cerebrod_gettimeofday_workaround_flag), - &conf->cerebrod_gettimeofday_workaround, - 0 + "cerebrod_gettimeofday_workaround", + CONFFILE_OPTION_BOOL, + -1, + conffile_bool, + 1, + 0, + &(conf->cerebrod_gettimeofday_workaround_flag), + &conf->cerebrod_gettimeofday_workaround, + 0 }, #if CEREBRO_DEBUG { - "cerebrod_alternate_hostname", - CONFFILE_OPTION_STRING, - -1, - _cb_cerebrod_alternate_hostname, - 1, - 0, - &(conf->cerebrod_alternate_hostname_flag), + "cerebrod_alternate_hostname", + CONFFILE_OPTION_STRING, + -1, + _cb_cerebrod_alternate_hostname, + 1, + 0, + &(conf->cerebrod_alternate_hostname_flag), conf, - 0 + 0 }, #endif /* CEREBRO_DEBUG */ }; @@ -1114,13 +1114,13 @@ _load_config_file(struct cerebro_config *conf, unsigned int *errnum) /* Its not an error if the default configuration file doesn't exist */ if (!strcmp(config_file, CEREBRO_CONFIG_FILE_DEFAULT) - && conffile_errnum(cf) == CONFFILE_ERR_EXIST) - goto out; + && conffile_errnum(cf) == CONFFILE_ERR_EXIST) + goto out; if (conffile_errmsg(cf, buf, CONFFILE_MAX_ERRMSGLEN) < 0) - CEREBRO_DBG(("conffile_parse: %d", conffile_errnum(cf))); + CEREBRO_DBG(("conffile_parse: %d", conffile_errnum(cf))); else - CEREBRO_DBG(("conffile_parse: %s", buf)); + CEREBRO_DBG(("conffile_parse: %s", buf)); if (errnum) *errnum = CEREBRO_ERR_CONFIG_FILE; diff --git a/src/libs/wrappers/wrappers.c b/src/libs/wrappers/wrappers.c index 1377aedc..476190e8 100644 --- a/src/libs/wrappers/wrappers.c +++ b/src/libs/wrappers/wrappers.c @@ -375,13 +375,13 @@ wrap_select(WRAPPERS_ARGS, int n, fd_set *readfds, fd_set *writefds, fd_set *exc if (rv < 0 && errno != EINTR) WRAPPERS_ERR_ERRNO("select"); if (rv < 0 && timeout) - { - Gettimeofday(&end, NULL); - /* delta = end-start */ - timersub(&end, &start, &delta); - /* timeout = timeout_orig-delta */ - timersub(&timeout_orig, &delta, timeout); - } + { + Gettimeofday(&end, NULL); + /* delta = end-start */ + timersub(&end, &start, &delta); + /* timeout = timeout_orig-delta */ + timersub(&timeout_orig, &delta, timeout); + } } while (rv < 0); @@ -588,24 +588,24 @@ wrap_gettimeofday_workaround(WRAPPERS_ARGS, struct timeval *tv, struct timezone while (1) { - if ((ret1 = gettimeofday(&tv1, tz))) - WRAPPERS_ERR_ERRNO("gettimeofday"); - if ((ret2 = gettimeofday(&tv2, tz))) - WRAPPERS_ERR_ERRNO("gettimeofday"); - - if (abs(tv1.tv_sec - tv2.tv_sec) < GETTIMEOFDAY_RANGE) - { - tv->tv_sec = tv2.tv_sec; - tv->tv_usec = tv2.tv_usec; - rv = ret2; - break; - } - else - cerebro_err_output("gettimeofday bad time read " - "(abs(%lu - %lu) >= %u) - retrying", - tv1.tv_sec, - tv2.tv_sec, - GETTIMEOFDAY_RANGE); + if ((ret1 = gettimeofday(&tv1, tz))) + WRAPPERS_ERR_ERRNO("gettimeofday"); + if ((ret2 = gettimeofday(&tv2, tz))) + WRAPPERS_ERR_ERRNO("gettimeofday"); + + if (abs(tv1.tv_sec - tv2.tv_sec) < GETTIMEOFDAY_RANGE) + { + tv->tv_sec = tv2.tv_sec; + tv->tv_usec = tv2.tv_usec; + rv = ret2; + break; + } + else + cerebro_err_output("gettimeofday bad time read " + "(abs(%lu - %lu) >= %u) - retrying", + tv1.tv_sec, + tv2.tv_sec, + GETTIMEOFDAY_RANGE); } } diff --git a/src/libs/wrappers/wrappers.h b/src/libs/wrappers/wrappers.h index 0a31c4d8..e8ecf1bd 100644 --- a/src/libs/wrappers/wrappers.h +++ b/src/libs/wrappers/wrappers.h @@ -325,7 +325,7 @@ int wrap_list_delete(WRAPPERS_ARGS, ListIterator i); #define Hash_remove(h, key) \ wrap_hash_remove(WRAPPERS_DEBUG_ARGS, h, key) #define Hash_remove_if(h, argf, arg) \ - wrap_hash_remove_if(WRAPPERS_DEBUG_ARGS,h, argf, arg) + wrap_hash_remove_if(WRAPPERS_DEBUG_ARGS,h, argf, arg) #define Hash_delete_if(h, argf, arg) \ wrap_hash_delete_if(WRAPPERS_DEBUG_ARGS, h, argf, arg) #define Hash_for_each(h, argf, arg) \ diff --git a/src/modules/clusterlist/cerebro_clusterlist_genders_util.c b/src/modules/clusterlist/cerebro_clusterlist_genders_util.c index 07580815..6dca2c16 100644 --- a/src/modules/clusterlist/cerebro_clusterlist_genders_util.c +++ b/src/modules/clusterlist/cerebro_clusterlist_genders_util.c @@ -64,10 +64,10 @@ cerebro_clusterlist_genders_setup(genders_t *gh, char *filename) if (genders_load_data(*gh, filename) < 0) { if (genders_errnum(*gh) == GENDERS_ERR_OPEN) - { - CEREBRO_ERR(("genders database '%s' cannot be opened", filename)); - goto cleanup; - } + { + CEREBRO_ERR(("genders database '%s' cannot be opened", filename)); + goto cleanup; + } else { CEREBRO_ERR(("genders_load_data: %s", genders_errormsg(*gh))); diff --git a/src/modules/metric/cerebro_metric_bytesin.c b/src/modules/metric/cerebro_metric_bytesin.c index 7287fe55..951f8783 100644 --- a/src/modules/metric/cerebro_metric_bytesin.c +++ b/src/modules/metric/cerebro_metric_bytesin.c @@ -64,8 +64,8 @@ bytesin_metric_get_metric_name(void) */ static int bytesin_metric_get_metric_value(unsigned int *metric_value_type, - unsigned int *metric_value_len, - void **metric_value) + unsigned int *metric_value_len, + void **metric_value) { u_int64_t bytesinval; u_int64_t *bytesinptr = NULL; diff --git a/src/modules/metric/cerebro_metric_loadavg.c b/src/modules/metric/cerebro_metric_loadavg.c index d392b38c..0d0a0dcc 100644 --- a/src/modules/metric/cerebro_metric_loadavg.c +++ b/src/modules/metric/cerebro_metric_loadavg.c @@ -77,8 +77,8 @@ static unsigned long int last_read = 0; */ int cerebro_metric_get_loadavgs(float *loadavg1, - float *loadavg5, - float *loadavg15) + float *loadavg5, + float *loadavg15) { int len, fd = -1; char buf[LOADAVG_BUFLEN]; @@ -94,27 +94,27 @@ cerebro_metric_get_loadavgs(float *loadavg1, if ((now.tv_sec - last_read) > LOADVAG_CACHETIMEOUT) { if ((fd = open(LOADAVG_FILE, O_RDONLY, 0)) < 0) - { - CEREBRO_ERR(("open: %s", strerror(errno))); - goto cleanup; - } + { + CEREBRO_ERR(("open: %s", strerror(errno))); + goto cleanup; + } memset(buf, '\0', LOADAVG_BUFLEN); if ((len = read(fd, buf, LOADAVG_BUFLEN)) < 0) - { - CEREBRO_ERR(("read: %s", strerror(errno))); - goto cleanup; - } + { + CEREBRO_ERR(("read: %s", strerror(errno))); + goto cleanup; + } if (sscanf(buf, - "%f %f %f", - &cache_loadavg1, - &cache_loadavg5, - &cache_loadavg15) != 3) - { - CEREBRO_DBG(("loadavg file parse error")); - goto cleanup; - } + "%f %f %f", + &cache_loadavg1, + &cache_loadavg5, + &cache_loadavg15) != 3) + { + CEREBRO_DBG(("loadavg file parse error")); + goto cleanup; + } last_read = now.tv_sec; } diff --git a/src/modules/metric/cerebro_metric_loadavg.h b/src/modules/metric/cerebro_metric_loadavg.h index 1352633b..a758a6e6 100644 --- a/src/modules/metric/cerebro_metric_loadavg.h +++ b/src/modules/metric/cerebro_metric_loadavg.h @@ -29,8 +29,8 @@ #define _CEREBRO_METRIC_LOADAVG int cerebro_metric_get_loadavgs(float *loadavg1, - float *loadavg5, - float *loadavg15); + float *loadavg5, + float *loadavg15); #endif /* _CEREBRO_METRIC_LOADAVG */ diff --git a/src/modules/metric/cerebro_metric_memfree.c b/src/modules/metric/cerebro_metric_memfree.c index 88b94047..2114b761 100644 --- a/src/modules/metric/cerebro_metric_memfree.c +++ b/src/modules/metric/cerebro_metric_memfree.c @@ -78,9 +78,9 @@ memfree_metric_get_metric_value(unsigned int *metric_value_type, } if (cerebro_metric_get_memory(NULL, - &memfreeval, - NULL, - NULL) < 0) + &memfreeval, + NULL, + NULL) < 0) goto cleanup; if (!(memfreeptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) diff --git a/src/modules/metric/cerebro_metric_memory.c b/src/modules/metric/cerebro_metric_memory.c index cceeaf5f..dd6a0f2d 100644 --- a/src/modules/metric/cerebro_metric_memory.c +++ b/src/modules/metric/cerebro_metric_memory.c @@ -82,9 +82,9 @@ static unsigned long int last_read = 0; */ static int _read_memory(int fd, - char *buf, - char *keyword, - u_int32_t *memvalptr) + char *buf, + char *keyword, + u_int32_t *memvalptr) { char *parseptr; unsigned long int memval; @@ -137,9 +137,9 @@ _read_memory(int fd, */ int cerebro_metric_get_memory(u_int32_t *memtotal, - u_int32_t *memfree, - u_int32_t *swaptotal, - u_int32_t *swapfree) + u_int32_t *memfree, + u_int32_t *swaptotal, + u_int32_t *swapfree) { int len, fd = -1; char buf[MEMORY_BUFLEN]; @@ -155,29 +155,29 @@ cerebro_metric_get_memory(u_int32_t *memtotal, if ((now.tv_sec - last_read) > MEMORY_CACHETIMEOUT) { if ((fd = open(MEMORY_FILE, O_RDONLY, 0)) < 0) - { - CEREBRO_ERR(("open: %s", strerror(errno))); - goto cleanup; - } + { + CEREBRO_ERR(("open: %s", strerror(errno))); + goto cleanup; + } memset(buf, '\0', MEMORY_BUFLEN); if ((len = read(fd, buf, MEMORY_BUFLEN)) < 0) - { - CEREBRO_ERR(("read: %s", strerror(errno))); - goto cleanup; - } + { + CEREBRO_ERR(("read: %s", strerror(errno))); + goto cleanup; + } if (_read_memory(fd, buf, MEMTOTAL_KEYWORD, &cache_memtotal) < 0) - goto cleanup; + goto cleanup; if (_read_memory(fd, buf, MEMFREE_KEYWORD, &cache_memfree) < 0) - goto cleanup; + goto cleanup; if (_read_memory(fd, buf, SWAPTOTAL_KEYWORD, &cache_swaptotal) < 0) - goto cleanup; + goto cleanup; if (_read_memory(fd, buf, SWAPFREE_KEYWORD, &cache_swapfree) < 0) - goto cleanup; + goto cleanup; last_read = now.tv_sec; } diff --git a/src/modules/metric/cerebro_metric_memory.h b/src/modules/metric/cerebro_metric_memory.h index cec3f059..8672ea85 100644 --- a/src/modules/metric/cerebro_metric_memory.h +++ b/src/modules/metric/cerebro_metric_memory.h @@ -29,8 +29,8 @@ #define _CEREBRO_METRIC_MEMORY int cerebro_metric_get_memory(u_int32_t *memtotal, - u_int32_t *memfree, - u_int32_t *swaptotal, - u_int32_t *swapfree); + u_int32_t *memfree, + u_int32_t *swaptotal, + u_int32_t *swapfree); #endif /* _CEREBRO_METRIC_MEMORY */ diff --git a/src/modules/metric/cerebro_metric_memtotal.c b/src/modules/metric/cerebro_metric_memtotal.c index aec3cd0a..83fe0484 100644 --- a/src/modules/metric/cerebro_metric_memtotal.c +++ b/src/modules/metric/cerebro_metric_memtotal.c @@ -78,9 +78,9 @@ memtotal_metric_get_metric_value(unsigned int *metric_value_type, } if (cerebro_metric_get_memory(&memtotalval, - NULL, - NULL, - NULL) < 0) + NULL, + NULL, + NULL) < 0) goto cleanup; if (!(memtotalptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) diff --git a/src/modules/metric/cerebro_metric_memused.c b/src/modules/metric/cerebro_metric_memused.c index d2cf94eb..7dd513a9 100644 --- a/src/modules/metric/cerebro_metric_memused.c +++ b/src/modules/metric/cerebro_metric_memused.c @@ -78,9 +78,9 @@ memused_metric_get_metric_value(unsigned int *metric_value_type, } if (cerebro_metric_get_memory(&memtotalval, - &memfreeval, - NULL, - NULL) < 0) + &memfreeval, + NULL, + NULL) < 0) goto cleanup; if (!(memusedptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) diff --git a/src/modules/metric/cerebro_metric_network.c b/src/modules/metric/cerebro_metric_network.c index 83cb179b..a2d8a702 100644 --- a/src/modules/metric/cerebro_metric_network.c +++ b/src/modules/metric/cerebro_metric_network.c @@ -80,11 +80,11 @@ static unsigned long int last_read = 0; */ int cerebro_metric_get_network(u_int64_t *bytesin, - u_int64_t *bytesout, - u_int32_t *packetsin, - u_int32_t *packetsout, - u_int32_t *rxerrs, - u_int32_t *txerrs) + u_int64_t *bytesout, + u_int32_t *packetsin, + u_int32_t *packetsout, + u_int32_t *rxerrs, + u_int32_t *txerrs) { int len, fd = -1; char buf[NETWORK_BUFLEN]; @@ -107,138 +107,138 @@ cerebro_metric_get_network(u_int64_t *bytesin, if ((now.tv_sec - last_read) > NETWORK_CACHETIMEOUT) { if ((fd = open(NETWORK_FILE, O_RDONLY, 0)) < 0) - { - CEREBRO_ERR(("open: %s", strerror(errno))); - goto cleanup; - } + { + CEREBRO_ERR(("open: %s", strerror(errno))); + goto cleanup; + } memset(buf, '\0', NETWORK_BUFLEN); if ((len = read(fd, buf, NETWORK_BUFLEN)) < 0) - { - CEREBRO_ERR(("read: %s", strerror(errno))); - goto cleanup; - } + { + CEREBRO_ERR(("read: %s", strerror(errno))); + goto cleanup; + } /* skip the first two lines of the file, which are headers, and * skip the local loopback interface */ parseptr = buf; if (!(parseptr = strstr(parseptr, "\n"))) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } parseptr++; if (!(parseptr = strstr(parseptr, "\n"))) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } parseptr++; if (!(parseptr = strstr(parseptr, "\n"))) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } parseptr++; while (strstr(parseptr, "\n")) - { - u_int64_t rx_bytes; - u_int64_t tx_bytes; - u_int32_t rx_packets, rx_errs; - u_int32_t tx_packets, tx_errs; - char *strptr; + { + u_int64_t rx_bytes; + u_int64_t tx_bytes; + u_int32_t rx_packets, rx_errs; + u_int32_t tx_packets, tx_errs; + char *strptr; - /* skip the device name */ - if (!(strptr = strstr(parseptr, ":"))) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } - strptr++; + /* skip the device name */ + if (!(strptr = strstr(parseptr, ":"))) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } + strptr++; - rx_bytes = strtoull(strptr, &strptr, 10); - if (!strptr) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } - rx_packets = strtoul(strptr, &strptr, 10); - if (!strptr) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } - rx_errs = strtoul(strptr, &strptr, 10); - if (!strptr) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } - (void)strtoul(strptr, &strptr, 10); /* drop */ - if (!strptr) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } - (void)strtoul(strptr, &strptr, 10); /* fifo */ - if (!strptr) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } - (void)strtoul(strptr, &strptr, 10); /* frame */ - if (!strptr) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } - (void)strtoul(strptr, &strptr, 10); /* compressed */ - if (!strptr) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } - (void)strtoul(strptr, &strptr, 10); /* multicast */ - if (!strptr) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } - tx_bytes = strtoull(strptr, &strptr, 10); - if (!strptr) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } - tx_packets = strtoul(strptr, &strptr, 10); - if (!strptr) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } - tx_errs = strtoul(strptr, &strptr, 10); - if (!strptr) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } + rx_bytes = strtoull(strptr, &strptr, 10); + if (!strptr) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } + rx_packets = strtoul(strptr, &strptr, 10); + if (!strptr) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } + rx_errs = strtoul(strptr, &strptr, 10); + if (!strptr) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } + (void)strtoul(strptr, &strptr, 10); /* drop */ + if (!strptr) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } + (void)strtoul(strptr, &strptr, 10); /* fifo */ + if (!strptr) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } + (void)strtoul(strptr, &strptr, 10); /* frame */ + if (!strptr) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } + (void)strtoul(strptr, &strptr, 10); /* compressed */ + if (!strptr) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } + (void)strtoul(strptr, &strptr, 10); /* multicast */ + if (!strptr) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } + tx_bytes = strtoull(strptr, &strptr, 10); + if (!strptr) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } + tx_packets = strtoul(strptr, &strptr, 10); + if (!strptr) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } + tx_errs = strtoul(strptr, &strptr, 10); + if (!strptr) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } - total_bytesin += rx_bytes; - total_packetsin += rx_packets; - total_rxerrs += rx_errs; - total_bytesout += tx_bytes; - total_packetsout += tx_packets; - total_txerrs += tx_errs; + total_bytesin += rx_bytes; + total_packetsin += rx_packets; + total_rxerrs += rx_errs; + total_bytesout += tx_bytes; + total_packetsout += tx_packets; + total_txerrs += tx_errs; - if (!(parseptr = strstr(parseptr, "\n"))) - { - CEREBRO_ERR(("%s parse error", NETWORK_FILE)); - goto cleanup; - } - parseptr++; - } + if (!(parseptr = strstr(parseptr, "\n"))) + { + CEREBRO_ERR(("%s parse error", NETWORK_FILE)); + goto cleanup; + } + parseptr++; + } cache_bytesin = total_bytesin; cache_bytesout = total_bytesout; diff --git a/src/modules/metric/cerebro_metric_packetsin.c b/src/modules/metric/cerebro_metric_packetsin.c index 6645285f..7a4abc70 100644 --- a/src/modules/metric/cerebro_metric_packetsin.c +++ b/src/modules/metric/cerebro_metric_packetsin.c @@ -64,8 +64,8 @@ packetsin_metric_get_metric_name(void) */ static int packetsin_metric_get_metric_value(unsigned int *metric_value_type, - unsigned int *metric_value_len, - void **metric_value) + unsigned int *metric_value_len, + void **metric_value) { u_int32_t packetsinval; u_int32_t *packetsinptr = NULL; diff --git a/src/modules/metric/cerebro_metric_packetsout.c b/src/modules/metric/cerebro_metric_packetsout.c index e1620ffb..af617eb2 100644 --- a/src/modules/metric/cerebro_metric_packetsout.c +++ b/src/modules/metric/cerebro_metric_packetsout.c @@ -64,8 +64,8 @@ packetsout_metric_get_metric_name(void) */ static int packetsout_metric_get_metric_value(unsigned int *metric_value_type, - unsigned int *metric_value_len, - void **metric_value) + unsigned int *metric_value_len, + void **metric_value) { u_int32_t packetsoutval; u_int32_t *packetsoutptr = NULL; diff --git a/src/modules/metric/cerebro_metric_rxerrs.c b/src/modules/metric/cerebro_metric_rxerrs.c index 68244092..e4875c45 100644 --- a/src/modules/metric/cerebro_metric_rxerrs.c +++ b/src/modules/metric/cerebro_metric_rxerrs.c @@ -64,8 +64,8 @@ rxerrs_metric_get_metric_name(void) */ static int rxerrs_metric_get_metric_value(unsigned int *metric_value_type, - unsigned int *metric_value_len, - void **metric_value) + unsigned int *metric_value_len, + void **metric_value) { u_int32_t rxerrsval; u_int32_t *rxerrsptr = NULL; diff --git a/src/modules/metric/cerebro_metric_swapfree.c b/src/modules/metric/cerebro_metric_swapfree.c index f22c092b..9b2377f4 100644 --- a/src/modules/metric/cerebro_metric_swapfree.c +++ b/src/modules/metric/cerebro_metric_swapfree.c @@ -78,9 +78,9 @@ swapfree_metric_get_metric_value(unsigned int *metric_value_type, } if (cerebro_metric_get_memory(NULL, - NULL, - NULL, - &swapfreeval) < 0) + NULL, + NULL, + &swapfreeval) < 0) goto cleanup; if (!(swapfreeptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) diff --git a/src/modules/metric/cerebro_metric_swaptotal.c b/src/modules/metric/cerebro_metric_swaptotal.c index f4901849..87d6b38e 100644 --- a/src/modules/metric/cerebro_metric_swaptotal.c +++ b/src/modules/metric/cerebro_metric_swaptotal.c @@ -78,9 +78,9 @@ swaptotal_metric_get_metric_value(unsigned int *metric_value_type, } if (cerebro_metric_get_memory(NULL, - NULL, - &swaptotalval, - NULL) < 0) + NULL, + &swaptotalval, + NULL) < 0) goto cleanup; if (!(swaptotalptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) diff --git a/src/modules/metric/cerebro_metric_swapused.c b/src/modules/metric/cerebro_metric_swapused.c index d7f8976b..a0724002 100644 --- a/src/modules/metric/cerebro_metric_swapused.c +++ b/src/modules/metric/cerebro_metric_swapused.c @@ -78,9 +78,9 @@ swapused_metric_get_metric_value(unsigned int *metric_value_type, } if (cerebro_metric_get_memory(NULL, - NULL, - &swaptotalval, - &swapfreeval) < 0) + NULL, + &swaptotalval, + &swapfreeval) < 0) goto cleanup; if (!(swapusedptr = (u_int32_t *)malloc(sizeof(u_int32_t)))) diff --git a/src/modules/metric/cerebro_metric_txerrs.c b/src/modules/metric/cerebro_metric_txerrs.c index ec60ac12..7e710ef0 100644 --- a/src/modules/metric/cerebro_metric_txerrs.c +++ b/src/modules/metric/cerebro_metric_txerrs.c @@ -64,8 +64,8 @@ txerrs_metric_get_metric_name(void) */ static int txerrs_metric_get_metric_value(unsigned int *metric_value_type, - unsigned int *metric_value_len, - void **metric_value) + unsigned int *metric_value_len, + void **metric_value) { u_int32_t txerrsval; u_int32_t *txerrsptr = NULL;