From 2bfa89ed011ed04b34e1f4c604cf0c639db04c06 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 24 Mar 2010 17:44:41 +0100 Subject: [PATCH] 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. --- src/utils_format_json.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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 ("]"); -- 2.30.2