X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fwrite_mongodb.c;h=9cddc9167fc4fcdeace97ad4df0bd725d264c298;hp=46b6d865be2d569a76b56c28f8b44c4d3d347b5f;hb=d486225f89ea52d8ed2b4242eba2ad94c409f837;hpb=7f38ca96e3a54a4b02475f857c7d79c6a1257ada diff --git a/src/write_mongodb.c b/src/write_mongodb.c index 46b6d865..9cddc916 100644 --- a/src/write_mongodb.c +++ b/src/write_mongodb.c @@ -50,8 +50,8 @@ struct wm_node_s { char *user; char *passwd; - _Bool store_rates; - _Bool connected; + bool store_rates; + bool connected; mongoc_client_t *client; mongoc_database_t *database; @@ -63,7 +63,7 @@ typedef struct wm_node_s wm_node_t; * Functions */ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */ - const value_list_t *vl, _Bool store_rates) { + const value_list_t *vl, bool store_rates) { bson_t *ret; bson_t subarray; gauge_t *rates; @@ -96,7 +96,7 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */ for (size_t i = 0; i < ds->ds_num; i++) { char key[16]; - snprintf(key, sizeof(key), "%zu", i); + snprintf(key, sizeof(key), "%" PRIsz, i); if (ds->ds[i].type == DS_TYPE_GAUGE) BSON_APPEND_DOUBLE(&subarray, key, vl->values[i].gauge); @@ -109,7 +109,7 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */ else if (ds->ds[i].type == DS_TYPE_ABSOLUTE) BSON_APPEND_INT64(&subarray, key, vl->values[i].absolute); else { - ERROR("write_mongodb plugin: Unknown ds_type %d for index %zu", + ERROR("write_mongodb plugin: Unknown ds_type %d for index %" PRIsz, ds->ds[i].type, i); bson_destroy(ret); return NULL; @@ -121,7 +121,7 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */ for (size_t i = 0; i < ds->ds_num; i++) { char key[16]; - snprintf(key, sizeof(key), "%zu", i); + snprintf(key, sizeof(key), "%" PRIsz, i); if (store_rates) BSON_APPEND_UTF8(&subarray, key, "gauge"); @@ -134,7 +134,7 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */ for (size_t i = 0; i < ds->ds_num; i++) { char key[16]; - snprintf(key, sizeof(key), "%zu", i); + snprintf(key, sizeof(key), "%" PRIsz, i); BSON_APPEND_UTF8(&subarray, key, ds->ds[i].name); } bson_append_array_end(ret, &subarray); /* }}} dsnames */ @@ -144,7 +144,7 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */ size_t error_location; if (!bson_validate(ret, BSON_VALIDATE_UTF8, &error_location)) { ERROR("write_mongodb plugin: Error in generated BSON document " - "at byte %zu", + "at byte %" PRIsz, error_location); bson_destroy(ret); return NULL; @@ -170,7 +170,7 @@ static int wm_initialize(wm_node_t *node) /* {{{ */ "authentication string."); mongoc_client_destroy(node->client); node->client = NULL; - node->connected = 0; + node->connected = false; return -1; } @@ -179,7 +179,7 @@ static int wm_initialize(wm_node_t *node) /* {{{ */ ERROR("write_mongodb plugin: Authenticating to [%s]:%d for database " "\"%s\" as user \"%s\" failed.", node->host, node->port, node->db, node->user); - node->connected = 0; + node->connected = false; sfree(uri); return -1; } @@ -190,7 +190,7 @@ static int wm_initialize(wm_node_t *node) /* {{{ */ "authentication string."); mongoc_client_destroy(node->client); node->client = NULL; - node->connected = 0; + node->connected = false; return -1; } @@ -198,7 +198,7 @@ static int wm_initialize(wm_node_t *node) /* {{{ */ if (!node->client) { ERROR("write_mongodb plugin: Connecting to [%s]:%d failed.", node->host, node->port); - node->connected = 0; + node->connected = false; sfree(uri); return -1; } @@ -210,11 +210,11 @@ static int wm_initialize(wm_node_t *node) /* {{{ */ ERROR("write_mongodb plugin: error creating/getting database"); mongoc_client_destroy(node->client); node->client = NULL; - node->connected = 0; + node->connected = false; return -1; } - node->connected = 1; + node->connected = true; return 0; } /* }}} int wm_initialize */ @@ -248,7 +248,7 @@ static int wm_write(const data_set_t *ds, /* {{{ */ mongoc_client_destroy(node->client); node->database = NULL; node->client = NULL; - node->connected = 0; + node->connected = false; pthread_mutex_unlock(&node->lock); bson_destroy(bson_record); return -1; @@ -263,7 +263,7 @@ static int wm_write(const data_set_t *ds, /* {{{ */ mongoc_client_destroy(node->client); node->database = NULL; node->client = NULL; - node->connected = 0; + node->connected = false; pthread_mutex_unlock(&node->lock); bson_destroy(bson_record); mongoc_collection_destroy(collection); @@ -291,7 +291,7 @@ static void wm_config_free(void *ptr) /* {{{ */ mongoc_client_destroy(node->client); node->database = NULL; node->client = NULL; - node->connected = 0; + node->connected = false; sfree(node->host); sfree(node); @@ -312,7 +312,7 @@ static int wm_config_node(oconfig_item_t *ci) /* {{{ */ return ENOMEM; } node->port = MONGOC_DEFAULT_PORT; - node->store_rates = 1; + node->store_rates = true; pthread_mutex_init(&node->lock, /* attr = */ NULL); status = cf_util_get_string_buffer(ci, node->name, sizeof(node->name));