tests: include json script shunit2 based testing
[project/libubox.git] / blobmsg_json.c
index ca9dd1a4a8eff1f959e0ae193e45d4e528e7e04e..18592111b4dd06346a3d3605a555707e84156e7f 100644 (file)
@@ -146,7 +146,7 @@ static bool blobmsg_puts(struct strbuf *s, const char *c, int len)
 static void add_separator(struct strbuf *s)
 {
        const char *indent_chars = "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
-       int len;
+       size_t len;
 
        if (!s->indent)
                return;
@@ -185,7 +185,6 @@ static void blobmsg_format_string(struct strbuf *s, const char *str)
                        break;
                case '"':
                case '\\':
-               case '/':
                        escape = *p;
                        break;
                default:
@@ -280,7 +279,7 @@ static void blobmsg_format_json_list(struct strbuf *s, struct blob_attr *attr, i
 {
        struct blob_attr *pos;
        bool first = true;
-       int rem = len;
+       size_t rem = len;
 
        blobmsg_puts(s, (array ? "[" : "{" ), 1);
        s->indent_level++;
@@ -316,7 +315,7 @@ static void setup_strbuf(struct strbuf *s, struct blob_attr *attr, blobmsg_json_
 
 char *blobmsg_format_json_with_cb(struct blob_attr *attr, bool list, blobmsg_json_format_t cb, void *priv, int indent)
 {
-       struct strbuf s;
+       struct strbuf s = {0};
        bool array;
        char *ret;
 
@@ -350,7 +349,7 @@ char *blobmsg_format_json_with_cb(struct blob_attr *attr, bool list, blobmsg_jso
 
 char *blobmsg_format_json_value_with_cb(struct blob_attr *attr, blobmsg_json_format_t cb, void *priv, int indent)
 {
-       struct strbuf s;
+       struct strbuf s = {0};
        char *ret;
 
        setup_strbuf(&s, attr, cb, priv, indent);