#include "utils_latency_config.h"
int latency_config_add_percentile(const char *plugin, latency_config_t *cl,
- oconfig_item_t *ci)
-{
- if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
- {
+ oconfig_item_t *ci) {
+ if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER)) {
ERROR("%s plugin: \"%s\" requires exactly one numeric argument.", plugin,
ci->key);
return (-1);
double percent = ci->values[0].value.number;
double *tmp;
- if ((percent <= 0.0) || (percent >= 100))
- {
+ if ((percent <= 0.0) || (percent >= 100)) {
ERROR("%s plugin: The value for \"%s\" must be between 0 and 100, "
"exclusively.",
plugin, ci->key);
tmp = realloc(cl->percentile,
sizeof(*cl->percentile) * (cl->percentile_num + 1));
- if (tmp == NULL)
- {
+ if (tmp == NULL) {
ERROR("%s plugin: realloc failed.", plugin);
return (ENOMEM);
}
} /* int latency_config_add_percentile */
int latency_config_add_rate(const char *plugin, latency_config_t *cl,
- oconfig_item_t *ci)
-{
- if ((ci->values_num != 2)
- || (ci->values[0].type != OCONFIG_TYPE_NUMBER)
- || (ci->values[1].type != OCONFIG_TYPE_NUMBER))
- {
+ oconfig_item_t *ci) {
+ if ((ci->values_num != 2) || (ci->values[0].type != OCONFIG_TYPE_NUMBER) ||
+ (ci->values[1].type != OCONFIG_TYPE_NUMBER)) {
ERROR("%s plugin: \"%s\" requires exactly two numeric arguments.", plugin,
ci->key);
return (-1);
}
if (ci->values[1].value.number &&
- ci->values[1].value.number <= ci->values[0].value.number)
- {
+ ci->values[1].value.number <= ci->values[0].value.number) {
ERROR("%s plugin: MIN must be less than MAX in \"%s\".", plugin, ci->key);
return (-1);
}
- if (ci->values[0].value.number < 0.001)
- {
+ if (ci->values[0].value.number < 0.001) {
ERROR("%s plugin: MIN must be greater or equal to 0.001 in \"%s\".", plugin,
ci->key);
return (-1);
cdtime_t *tmp;
tmp = realloc(cl->rates, sizeof(*cl->rates) * (cl->rates_num + 1) * 2);
- if (tmp == NULL)
- {
+ if (tmp == NULL) {
ERROR("%s plugin: realloc failed.", plugin);
return (ENOMEM);
}
return (0);
} /* int latency_config_add_rate */
-int latency_config_copy(latency_config_t *dst, const latency_config_t src)
-{
+int latency_config_copy(latency_config_t *dst, const latency_config_t src) {
*dst = (latency_config_t){
- .rates = NULL,
- .rates_num = src.rates_num,
- .rates_type = NULL,
- .percentile = NULL,
- .percentile_num = src.percentile_num,
- .percentile_type = NULL,
+ .rates = NULL,
+ .rates_num = src.rates_num,
+ .rates_type = NULL,
+ .percentile = NULL,
+ .percentile_num = src.percentile_num,
+ .percentile_type = NULL,
};
/* Copy percentiles configuration */
memcpy(dst->percentile, src.percentile,
(sizeof(*dst->percentile) * (src.percentile_num)));
- if (src.percentile_type != NULL)
- {
+ if (src.percentile_type != NULL) {
dst->percentile_type = strdup(src.percentile_type);
- if (dst->percentile_type == NULL)
- {
+ if (dst->percentile_type == NULL) {
latency_config_free(*dst);
return (-1);
}
/* Copy rates configuration */
dst->rates_num = src.rates_num;
dst->rates = calloc(src.rates_num * 2, sizeof(*dst->rates));
- if (dst->rates == NULL)
- {
+ if (dst->rates == NULL) {
latency_config_free(*dst);
return (-1);
}
memcpy(dst->rates, src.rates, (sizeof(*dst->rates) * (src.rates_num) * 2));
- if (src.rates_type != NULL)
- {
+ if (src.rates_type != NULL) {
dst->rates_type = strdup(src.rates_type);
- if (dst->rates_type == NULL)
- {
+ if (dst->rates_type == NULL) {
latency_config_free(*dst);
return (-1);
}