From c05289d4e4cd37ce21e2e7567d497f0682f8895b Mon Sep 17 00:00:00 2001 From: Lauri Jakku Date: Thu, 19 Dec 2019 18:36:15 +0200 Subject: [PATCH] Pretty neat readability change of json_object_to_json_string_length() --- json_object.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/json_object.c b/json_object.c index aa72a22..82bb34f 100644 --- a/json_object.c +++ b/json_object.c @@ -149,9 +149,9 @@ static int json_escape_str(struct printbuf *pb, const char *str, int len, int fl str + start_offset, pos - start_offset); snprintf(sbuf, sizeof(sbuf), - "\\u00%c%c", - json_hex_chars[c >> 4], - json_hex_chars[c & 0xf]); + "\\u00%c%c", + json_hex_chars[c >> 4], + json_hex_chars[c & 0xf]); printbuf_memappend_fast(pb, sbuf, (int) sizeof(sbuf) - 1); start_offset = ++pos; } else @@ -331,6 +331,8 @@ const char* json_object_to_json_string_length(struct json_object *jso, int flags s = 4; r = "null"; + /* no clutter and no fail cases after */ + if (jso) { if ( jso->_pb == NULL )