summaryrefslogtreecommitdiffstats
path: root/src/vat2/test/vat2_test.c
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2021-02-11 11:13:46 +0100
committerNeale Ranns <neale@graphiant.com>2021-02-11 15:30:11 +0000
commitfb0afab7f539f1e28fc01d98b446e3ce1e9812d0 (patch)
tree7c5118b66cd6b084f1c00510b26051a0a5af7e9a /src/vat2/test/vat2_test.c
parentc25882c28e081bf6a2bd4e914ac85f6e4edbfc3d (diff)
vppapigen: fix fromjson coverity errors in generation
Fix memory leak coverity errors where free was not called on error conditions. Or called twice. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I21cffa8b01e4f72f10501f202f6a762ae300a941 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/vat2/test/vat2_test.c')
-rw-r--r--src/vat2/test/vat2_test.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/vat2/test/vat2_test.c b/src/vat2/test/vat2_test.c
index fe788f127c6..b5346eeea47 100644
--- a/src/vat2/test/vat2_test.c
+++ b/src/vat2/test/vat2_test.c
@@ -96,24 +96,38 @@ runtest (char *s, bool should_fail)
}
struct msgs msgs[] = {
-{
- .name = "test_prefix",
- .tojson = (tojson_fn_t)vl_api_test_prefix_t_tojson,
- .fromjson = (fromjson_fn_t)vl_api_test_prefix_t_fromjson,
-},
-{
- .name = "test_enum",
- .tojson = (tojson_fn_t)vl_api_test_enum_t_tojson,
- .fromjson = (fromjson_fn_t)vl_api_test_enum_t_fromjson,
-},
+ {
+ .name = "test_prefix",
+ .tojson = (tojson_fn_t) vl_api_test_prefix_t_tojson,
+ .fromjson = (fromjson_fn_t) vl_api_test_prefix_t_fromjson,
+ },
+ {
+ .name = "test_enum",
+ .tojson = (tojson_fn_t) vl_api_test_enum_t_tojson,
+ .fromjson = (fromjson_fn_t) vl_api_test_enum_t_fromjson,
+ },
+ {
+ .name = "test_string",
+ .tojson = (tojson_fn_t) vl_api_test_string_t_tojson,
+ .fromjson = (fromjson_fn_t) vl_api_test_string_t_fromjson,
+ },
+ {
+ .name = "test_string2",
+ .tojson = (tojson_fn_t) vl_api_test_string2_t_tojson,
+ .fromjson = (fromjson_fn_t) vl_api_test_string2_t_fromjson,
+ },
};
struct tests tests[] = {
- {.s = "{\"_msgname\": \"test_prefix\", \"pref\": \"2001:db8::/64\"}"},
- {.s = "{\"_msgname\": \"test_prefix\", \"pref\": \"192.168.10.0/24\"}"},
- {.s = "{\"_msgname\": \"test_enum\", \"flags\": [\"RED\", \"BLUE\"]}"},
- {.s = "{\"_msgname\": \"test_enum\", \"flags\": [\"BLACK\", \"BLUE\"]}",
- .should_fail = 1},
+ { .s = "{\"_msgname\": \"test_prefix\", \"pref\": \"2001:db8::/64\"}" },
+ { .s = "{\"_msgname\": \"test_prefix\", \"pref\": \"192.168.10.0/24\"}" },
+ { .s = "{\"_msgname\": \"test_enum\", \"flags\": [\"RED\", \"BLUE\"]}" },
+ { .s = "{\"_msgname\": \"test_enum\", \"flags\": [\"BLACK\", \"BLUE\"]}",
+ .should_fail = 1 },
+ { .s = "{\"_msgname\": \"test_string\", \"str\": {\"str\": \"Test string "
+ "type\"}}" },
+ { .s =
+ "{\"_msgname\": \"test_string2\", \"str\": \"Test string toplevel\"}" },
};
int main (int argc, char **argv)