X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_cache.c;h=a63c7d1c9b1cba770447a6a9080d0c6a6c7ea235;hb=3f391479bfc45d0ff6e0c7b87c899e41a192f392;hp=6d96516900c7f9d03d1cc39a2b3abef8c89a96f8;hpb=b24d793d347f6f6c8b29e25758fa2d925fb7e011;p=collectd.git diff --git a/src/utils_cache.c b/src/utils_cache.c index 6d965169..a63c7d1c 100644 --- a/src/utils_cache.c +++ b/src/utils_cache.c @@ -156,13 +156,12 @@ static int uc_send_notification (const char *name) return (-1); } - snprintf (n.message, sizeof (n.message), + ssnprintf (n.message, sizeof (n.message), "%s has not been updated for %i seconds.", name, (int) (n.time - ce->last_update)); pthread_mutex_unlock (&cache_lock); - n.message[sizeof (n.message) - 1] = '\0'; plugin_dispatch_notification (&n); return (0); @@ -187,6 +186,7 @@ static int uc_insert (const data_set_t *ds, const value_list_t *vl, ce = cache_alloc (ds->ds_num); if (ce == NULL) { + sfree (key_copy); ERROR ("uc_insert: cache_alloc (%i) failed.", ds->ds_num); return (-1); } @@ -262,6 +262,7 @@ int uc_check_timeout (void) { ERROR ("uc_purge: realloc failed."); c_avl_iterator_destroy (iter); + pthread_mutex_unlock (&cache_lock); return (-1); } @@ -326,7 +327,7 @@ int uc_check_timeout (void) } else { - WARNING ("uc_check_timeout: ut_check_interesting (%s) returned ", + WARNING ("uc_check_timeout: ut_check_interesting (%s) returned " "invalid status %i.", keys[i], status); } @@ -451,10 +452,9 @@ int uc_update (const data_set_t *ds, const value_list_t *vl) n.severity = NOTIF_OKAY; n.time = vl->time; - snprintf (n.message, sizeof (n.message), + ssnprintf (n.message, sizeof (n.message), "Received a value for %s. It was missing for %u seconds.", name, (unsigned int) update_delay); - n.message[sizeof (n.message) - 1] = '\0'; plugin_dispatch_notification (&n); @@ -512,7 +512,7 @@ gauge_t *uc_get_rate (const data_set_t *ds, const value_list_t *vl) if (FORMAT_VL (name, sizeof (name), vl, ds) != 0) { - ERROR ("uc_insert: FORMAT_VL failed."); + ERROR ("utils_cache: uc_get_rate: FORMAT_VL failed."); return (NULL); } @@ -522,10 +522,10 @@ gauge_t *uc_get_rate (const data_set_t *ds, const value_list_t *vl) /* 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 %i.", + "but uc_get_rate_by_name returned %zu.", ds->type, ds->ds_num, ret_num); sfree (ret); return (NULL);