X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_sensu.c;h=a9f621d7d5af121498827d489a228a82e2fbfe08;hb=b34cd94ec5b8b46fb0610c020c49f20e6d3980a8;hp=a34f0cf9d28b7940488ccf2d7cbda380673c7c0d;hpb=72a71d40195511fae335e1384cb2eba606ad5caa;p=collectd.git diff --git a/src/write_sensu.c b/src/write_sensu.c index a34f0cf9..a9f621d7 100644 --- a/src/write_sensu.c +++ b/src/write_sensu.c @@ -454,7 +454,7 @@ static char *sensu_value_to_json(struct sensu_host const *host, /* {{{ */ // incorporate the data source index { char ds_index[DATA_MAX_NAME_LEN]; - snprintf(ds_index, sizeof(ds_index), "%zu", index); + snprintf(ds_index, sizeof(ds_index), "%" PRIsz, index); res = my_asprintf(&temp_str, "%s, \"collectd_data_source_index\": %s", ret_str, ds_index); free(ret_str); @@ -519,7 +519,8 @@ static char *sensu_value_to_json(struct sensu_host const *host, /* {{{ */ return NULL; } } else { - res = my_asprintf(&value_str, "%llu", vl->values[index].counter); + res = my_asprintf(&value_str, "%" PRIu64, + (uint64_t)vl->values[index].counter); if (res == -1) { free(ret_str); ERROR("write_sensu plugin: Unable to alloc memory"); @@ -626,7 +627,7 @@ static char *replace_str(const char *str, const char *old, /* {{{ */ r += newlen; p = q + oldlen; } - strncpy(r, p, strlen(p)); + sstrncpy(r, p, sizeof(r)); return ret; } /* }}} char *replace_str */ @@ -996,7 +997,10 @@ static void sensu_free(void *p) /* {{{ */ sfree(host->separator); free_str_list(&(host->metric_handlers)); free_str_list(&(host->notification_handlers)); + + pthread_mutex_unlock(&host->lock); pthread_mutex_destroy(&host->lock); + sfree(host); } /* }}} void sensu_free */