Skip to content

Commit

Permalink
Merge pull request #4158 from octo/write_mongodb/format-truncation
Browse files Browse the repository at this point in the history
Write MongoDB plugin: fix format trunction errors.
  • Loading branch information
octo authored Nov 24, 2023
2 parents e45a7c0 + 9db1fd4 commit fd1eeb1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/write_mongodb.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */

BSON_APPEND_ARRAY_BEGIN(ret, "values", &subarray); /* {{{ */
for (size_t i = 0; i < ds->ds_num; i++) {
char key[16];
char key[32] = {0};

snprintf(key, sizeof(key), "%" PRIsz, i);
ssnprintf(key, sizeof(key), "%" PRIsz, i);

if (ds->ds[i].type == DS_TYPE_GAUGE)
BSON_APPEND_DOUBLE(&subarray, key, vl->values[i].gauge);
Expand All @@ -119,9 +119,9 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */

BSON_APPEND_ARRAY_BEGIN(ret, "dstypes", &subarray); /* {{{ */
for (size_t i = 0; i < ds->ds_num; i++) {
char key[16];
char key[32] = {0};

snprintf(key, sizeof(key), "%" PRIsz, i);
ssnprintf(key, sizeof(key), "%" PRIsz, i);

if (store_rates)
BSON_APPEND_UTF8(&subarray, key, "gauge");
Expand All @@ -132,9 +132,9 @@ static bson_t *wm_create_bson(const data_set_t *ds, /* {{{ */

BSON_APPEND_ARRAY_BEGIN(ret, "dsnames", &subarray); /* {{{ */
for (size_t i = 0; i < ds->ds_num; i++) {
char key[16];
char key[32] = {0};

snprintf(key, sizeof(key), "%" PRIsz, i);
ssnprintf(key, sizeof(key), "%" PRIsz, i);
BSON_APPEND_UTF8(&subarray, key, ds->ds[i].name);
}
bson_append_array_end(ret, &subarray); /* }}} dsnames */
Expand Down

0 comments on commit fd1eeb1

Please sign in to comment.