status = ssnprintf (credentials, sizeof (credentials), "%s:%s",
user, (pass == NULL) ? "" : pass);
- if (status >= sizeof (credentials))
+ if ((status < 0) || ((size_t) status >= sizeof (credentials)))
{
ERROR ("apache plugin: init: Returning an error "
"because the credentials have been "
static int ascent_submit_players (player_stats_t *ps) /* {{{ */
{
- int i;
+ size_t i;
gauge_t value;
for (i = 0; i < RACES_LIST_LENGTH; i++)
{
if (pi->race >= 0)
{
- if ((pi->race >= RACES_LIST_LENGTH)
+ if (((size_t) pi->race >= RACES_LIST_LENGTH)
|| (races_list[pi->race] == NULL))
ERROR ("ascent plugin: Ignoring invalid numeric race %i.", pi->race);
else
if (pi->class >= 0)
{
- if ((pi->class >= CLASSES_LIST_LENGTH)
+ if (((size_t) pi->class >= CLASSES_LIST_LENGTH)
|| (classes_list[pi->class] == NULL))
ERROR ("ascent plugin: Ignoring invalid numeric class %i.", pi->class);
else
if (pi->gender >= 0)
{
- if ((pi->gender >= GENDERS_LIST_LENGTH)
+ if (((size_t) pi->gender >= GENDERS_LIST_LENGTH)
|| (genders_list[pi->gender] == NULL))
ERROR ("ascent plugin: Ignoring invalid numeric gender %i.",
pi->gender);
status = ssnprintf (credentials, sizeof (credentials), "%s:%s",
user, (pass == NULL) ? "" : pass);
- if (status >= sizeof (credentials))
+ if ((status < 0) || ((size_t) status >= sizeof (credentials)))
{
ERROR ("ascent plugin: ascent_init: Returning an error because the "
"credentials have been truncated.");
return (RET_UNKNOWN);
}
- for (i = 0; i < match_ds_num_g; i++)
+ for (i = 0; i < (size_t) match_ds_num_g; i++)
{
size_t j;
int num_okay = 0;
const char *status_str = "UNKNOWN";
int status_code = RET_UNKNOWN;
- int i;
+ size_t i;
for (i = 0; i < values_num; i++)
{
static int do_check_con_average (size_t values_num,
double *values, char **values_names)
{
- int i;
+ size_t i;
double total;
int total_num;
double average;
static int do_check_con_sum (size_t values_num,
double *values, char **values_names)
{
- int i;
+ size_t i;
double total;
int total_num;
const char *status_str = "UNKNOWN";
static int do_check_con_percentage (size_t values_num,
double *values, char **values_names)
{
- int i;
+ size_t i;
double sum = 0.0;
double percentage;
char *saveptr;
int last_is_file = 1;
int path_is_absolute = 0;
- int len;
+ size_t len;
int i;
/*
status = ssnprintf (name, sizeof (name), "%s/%s",
dir, de->d_name);
- if (status >= sizeof (name))
+ if ((status < 0) || ((size_t) status >= sizeof (name)))
{
ERROR ("configfile: Not including `%s/%s' because its"
" name is too long.",
int status;
const char *path_ptr;
wordexp_t we;
- int i;
+ size_t i;
if (depth >= CF_MAX_DEPTH)
{
/* Update the `iflist'. It's used to know which interfaces exist and query
* them later for qdiscs and classes. */
- if (msg->ifi_index >= iflist_len)
+ if ((msg->ifi_index >= 0) && ((size_t) msg->ifi_index >= iflist_len))
{
char **temp;
return (0);
}
- if (msg->tcm_ifindex >= iflist_len)
+ if ((msg->tcm_ifindex >= 0)
+ && ((size_t) msg->tcm_ifindex >= iflist_len))
{
ERROR ("netlink plugin: qos_filter: msg->tcm_ifindex = %i "
">= iflist_len = %zu",
/* `link_filter' will update `iflist' which is used here to iterate over all
* interfaces. */
- for (ifindex = 0; ifindex < iflist_len; ifindex++)
+ for (ifindex = 0; (size_t) ifindex < iflist_len; ifindex++)
{
- int type_index;
+ size_t type_index;
if (iflist[ifindex] == NULL)
continue;
exp_size = 3 * sizeof (uint16_t)
+ pkg_numval * (sizeof (uint8_t) + sizeof (value_t));
- if (buffer_len < exp_size)
+ if ((buffer_len < 0) || ((size_t) buffer_len < exp_size))
{
WARNING ("network plugin: parse_part_values: "
"Packet too short: "
uint16_t pkg_length;
uint16_t pkg_type;
- if (buffer_len < exp_size)
+ if ((buffer_len < 0) || ((size_t) buffer_len < exp_size))
{
WARNING ("network plugin: parse_part_number: "
"Packet too short: "
uint16_t pkg_length;
uint16_t pkg_type;
- if (buffer_len < header_size)
+ if ((buffer_len < 0) || ((size_t) buffer_len < header_size))
{
WARNING ("network plugin: parse_part_string: "
"Packet too short: "
/* Check that the package data fits into the output buffer.
* The previous if-statement ensures that:
* `pkg_length > header_size' */
- if ((pkg_length - header_size) > output_len)
+ if ((output_len < 0)
+ || ((size_t) output_len < ((size_t) pkg_length - header_size)))
{
WARNING ("network plugin: parse_part_string: "
"Output buffer too small.");
if (user != NULL)
{
- if (ssnprintf (credentials, sizeof (credentials),
- "%s:%s", user, pass == NULL ? "" : pass) >= sizeof (credentials))
+ int status = ssnprintf (credentials, sizeof (credentials),
+ "%s:%s", user, pass == NULL ? "" : pass);
+ if ((status < 0) || ((size_t) status >= sizeof (credentials)))
{
ERROR ("nginx plugin: Credentials would have been truncated.");
return (-1);
int ret;
struct stat statbuf;
struct dirent *de;
+ int status;
DEBUG ("type = %s", type);
/* `cpu' should not match `cpufreq'. To solve this we add `.so' to the
* type when matching the filename */
- if (ssnprintf (typename, sizeof (typename),
- "%s.so", type) >= sizeof (typename))
+ status = ssnprintf (typename, sizeof (typename), "%s.so", type);
+ if ((status < 0) || ((size_t) status >= sizeof (typename)))
{
WARNING ("snprintf: truncated: `%s.so'", type);
return (-1);
if (strncasecmp (de->d_name, typename, typename_len))
continue;
- if (ssnprintf (filename, sizeof (filename),
- "%s/%s", dir, de->d_name) >= sizeof (filename))
+ status = ssnprintf (filename, sizeof (filename),
+ "%s/%s", dir, de->d_name);
+ if ((status < 0) || ((size_t) status >= sizeof (filename)))
{
WARNING ("snprintf: truncated: `%s/%s'", dir, de->d_name);
continue;
n = 0;
while (42) {
- size_t status;
+ ssize_t status;
status = read (fd, (void *)buf_ptr, len);
return (-1);
}
- hd->interval = (int) ci->values[0].value.number;
- if (hd->interval < 0)
- hd->interval = 0;
+ hd->interval = ci->values[0].value.number >= 0
+ ? (uint32_t) ci->values[0].value.number
+ : 0;
return (0);
} /* int csnmp_config_add_host_interval */
break;
}
- for (i = 0; i < oid_list_len; i++)
+ for (i = 0; (uint32_t) i < oid_list_len; i++)
snmp_add_null_var (req, oid_list[i].oid, oid_list[i].oid_len);
res = NULL;
time_end = time (NULL);
DEBUG ("snmp plugin: csnmp_read_host (%s) finished at %u;", host->name,
(unsigned int) time_end);
- if ((time_end - time_start) > host->interval)
+ if ((uint32_t) (time_end - time_start) > host->interval)
{
WARNING ("snmp plugin: Host `%s' should be queried every %i seconds, "
"but reading all values takes %u seconds.",
{
host->interval = interval_g;
}
- else if (host->interval < interval_g)
+ else if (host->interval < (uint32_t) interval_g)
{
host->interval = interval_g;
WARNING ("snmp plugin: Data for host `%s' will be collected every %i seconds.",
static int ctail_read (void)
{
int success = 0;
- int i;
+ size_t i;
for (i = 0; i < tail_match_list_num; i++)
{
static int ctail_shutdown (void)
{
- int i;
+ size_t i;
for (i = 0; i < tail_match_list_num; i++)
{
if (device_list && ignorelist_match (device_list, name))
return -1;
- len = snprintf (filename, sizeof (filename), "%s/%s/temp", dirname_sysfs, name);
- if ((len < 0) || ((unsigned int)len >= sizeof (filename)))
+ len = snprintf (filename, sizeof (filename),
+ "%s/%s/temp", dirname_sysfs, name);
+ if ((len < 0) || ((size_t) len >= sizeof (filename)))
return -1;
len = read_file_contents (filename, data, sizeof(data));
}
}
- len = snprintf (filename, sizeof (filename), "%s/%s/cur_state", dirname_sysfs, name);
- if ((len < 0) || ((unsigned int)len >= sizeof (filename)))
+ len = snprintf (filename, sizeof (filename),
+ "%s/%s/cur_state", dirname_sysfs, name);
+ if ((len < 0) || ((size_t) len >= sizeof (filename)))
return -1;
len = read_file_contents (filename, data, sizeof(data));
* temperature: 55 C
*/
- len = snprintf (filename, sizeof (filename), "%s/%s/temperature", dirname_procfs, name);
- if ((len < 0) || ((unsigned int)len >= sizeof (filename)))
+ len = snprintf (filename, sizeof (filename),
+ "%s/%s/temperature", dirname_procfs, name);
+ if ((len < 0) || ((size_t) len >= sizeof (filename)))
return -1;
len = read_file_contents (filename, data, sizeof(data));
- if (len > sizeof(str_temp) && data[--len] == '\n' && !strncmp(data, str_temp, sizeof(str_temp)-1)) {
+ if ((len > 0) && ((size_t) len > sizeof(str_temp))
+ && (data[--len] == '\n')
+ && (! strncmp(data, str_temp, sizeof(str_temp)-1))) {
char *endptr = NULL;
double temp;
double celsius, add;
/* This is important - the caller has no other way of knowing how many
* values are returned. */
- if (ret_num != ds->ds_num)
+ if (ret_num != (size_t) ds->ds_num)
{
ERROR ("utils_cache: uc_get_rate: ds[%s] has %i values, "
"but uc_get_rate_by_name returned %zu.",
const data_set_t *ds;
int status;
- int i;
+ size_t i;
if ((fh == NULL) || (buffer == NULL))
return (-1);
return (-1);
}
- if (ds->ds_num != values_num)
+ if ((size_t) ds->ds_num != values_num)
{
ERROR ("ds[%s]->ds_num = %i, "
"but uc_get_rate_by_name returned %u values.",
if ((begin < 0) || (end < 0) || (begin >= end))
return (NULL);
- if (end > (strlen (str) + 1))
+ if ((size_t) end > (strlen (str) + 1))
{
ERROR ("utils_match: match_substr: `end' points after end of string.");
return (NULL);
regmatch_t re_match[32];
char *matches[32];
size_t matches_num;
- int i;
+ size_t i;
if ((obj == NULL) || (str == NULL))
return (-1);
for (j = 0; j < rra_types_num; j++)
{
+ int status;
+
if (rra_num >= rra_max)
break;
- if (ssnprintf (buffer, sizeof (buffer), "RRA:%s:%3.1f:%u:%u",
- rra_types[j], cfg->xff,
- cdp_len, cdp_num) >= sizeof (buffer))
+ status = ssnprintf (buffer, sizeof (buffer), "RRA:%s:%3.1f:%u:%u",
+ rra_types[j], cfg->xff, cdp_len, cdp_num);
+
+ if ((status < 0) || ((size_t) status >= sizeof (buffer)))
{
ERROR ("rra_get: Buffer would have been truncated.");
continue;
d->name, type,
(cfg->heartbeat > 0) ? cfg->heartbeat : (2 * vl->interval),
min, max);
- if ((status < 1) || (status >= sizeof (buffer)))
+ if ((status < 1) || ((size_t) status >= sizeof (buffer)))
break;
ds_def[ds_num] = sstrdup (buffer);
|| (NULL == replacement))
return NULL;
- sstrncpy (buf_ptr, string, (off1 + 1 > buflen) ? buflen : off1 + 1);
+ sstrncpy (buf_ptr, string,
+ ((size_t)off1 + 1 > buflen) ? buflen : (size_t)off1 + 1);
buf_ptr += off1;
len -= off1;
int __attribute__((unused)) buflen)
{
cu_tail_match_t *obj = (cu_tail_match_t *) data;
- int i;
+ size_t i;
for (i = 0; i < obj->matches_num; i++)
match_apply (obj->matches[i].match, buf);
void tail_match_destroy (cu_tail_match_t *obj)
{
- int i;
+ size_t i;
if (obj == NULL)
return;
{
char buffer[4096];
int status;
- int i;
+ size_t i;
status = cu_tail_read (obj->tail, buffer, sizeof (buffer), tail_callback,
(void *) obj);
while (42)
{
- size_t len;
+ int len;
char file[BUFSIZE];
FILE *fh;
if (dent->d_name[0] == '.')
continue;
- len = snprintf (file, sizeof (file), PROCDIR "/%s", dent->d_name);
+ len = ssnprintf (file, sizeof (file), PROCDIR "/%s", dent->d_name);
if ((len < 0) || (len >= BUFSIZE))
continue;
/* socket message accounting */
len = ssnprintf (file, sizeof (file),
PROCDIR "/%s/cacct", dent->d_name);
- if ((len < 0) || (len >= sizeof (file)))
+ if ((len < 0) || ((size_t) len >= sizeof (file)))
continue;
if (NULL == (fh = fopen (file, "r")))
/* thread information and load */
len = ssnprintf (file, sizeof (file),
PROCDIR "/%s/cvirt", dent->d_name);
- if ((len < 0) || (len >= sizeof (file)))
+ if ((len < 0) || ((size_t) len >= sizeof (file)))
continue;
if (NULL == (fh = fopen (file, "r")))
/* processes and memory usage */
len = ssnprintf (file, sizeof (file),
PROCDIR "/%s/limit", dent->d_name);
- if ((len < 0) || (len >= sizeof (file)))
+ if ((len < 0) || ((size_t) len >= sizeof (file)))
continue;
if (NULL == (fh = fopen (file, "r")))