From: Vincent Fu Date: Tue, 7 Jan 2025 20:56:19 +0000 (+0000) Subject: json: allow empty string values X-Git-Tag: fio-3.39~13 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=4a1f2a5b76b768a237ece419379bb99e94cb0523;p=fio.git json: allow empty string values The JSON standard permits empty strings. Currently fio's JSON module returns an error when it encounters an empty string. Change this to allow empty strings. https://www.json.org/ is the reference I used for the JSON standard. This is needed for upcoming patches to support FIO_OPT_STR_SET job options (norandommap, time_based, etc) that are enabled when the option is included without specifying a value for it. The value for these options is best represented by an empty string. Disallowing empty string values would prevent these options from appearing in job option dictionaries in the JSON output. Signed-off-by: Vincent Fu --- diff --git a/json.c b/json.c index cd3d5d74..6375b3c2 100644 --- a/json.c +++ b/json.c @@ -56,9 +56,6 @@ static char *strdup_escape(const char *str) char *p, *ret; int escapes; - if (!strlen(str)) - return NULL; - escapes = 0; while ((input = strpbrk(input, "\\\"")) != NULL) { escapes++;