From: Florian Forster Date: Wed, 24 Mar 2010 16:44:41 +0000 (+0100) Subject: src/utils_format_json.c: Use a format string to add strings to the buffer. X-Git-Tag: collectd-4.10.0~44 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2bfa89ed011ed04b34e1f4c604cf0c639db04c06;p=collectd.git src/utils_format_json.c: Use a format string to add strings to the buffer. While I hope that DS names can be trusted, I'm feeling more comfortable this way nonetheless. --- diff --git a/src/utils_format_json.c b/src/utils_format_json.c index 1ab03e1e..ac88c0fa 100644 --- a/src/utils_format_json.c +++ b/src/utils_format_json.c @@ -168,7 +168,7 @@ static int dstypes_to_json (char *buffer, size_t buffer_size, /* {{{ */ else if (((size_t) status) >= (buffer_size - offset)) \ return (-ENOMEM); \ else \ - offset += ((size_t) status); \ + offset += ((size_t) status); \ } while (0) BUFFER_ADD ("["); @@ -177,9 +177,7 @@ static int dstypes_to_json (char *buffer, size_t buffer_size, /* {{{ */ if (i > 0) BUFFER_ADD (","); - BUFFER_ADD ("\""); - BUFFER_ADD(DS_TYPE_TO_STRING(ds->ds[i].type)); - BUFFER_ADD ("\""); + BUFFER_ADD ("\"%s\"", DS_TYPE_TO_STRING (ds->ds[i].type)); } /* for ds->ds_num */ BUFFER_ADD ("]"); @@ -207,7 +205,7 @@ static int dsnames_to_json (char *buffer, size_t buffer_size, /* {{{ */ else if (((size_t) status) >= (buffer_size - offset)) \ return (-ENOMEM); \ else \ - offset += ((size_t) status); \ + offset += ((size_t) status); \ } while (0) BUFFER_ADD ("["); @@ -216,10 +214,7 @@ static int dsnames_to_json (char *buffer, size_t buffer_size, /* {{{ */ if (i > 0) BUFFER_ADD (","); - BUFFER_ADD ("\""); - BUFFER_ADD(ds->ds[i].name); - BUFFER_ADD ("\""); - + BUFFER_ADD ("\"%s\"", ds->ds[i].name); } /* for ds->ds_num */ BUFFER_ADD ("]");