X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvat2%2Fjsonconvert.c;h=1437b90688a76c4d5d23b26bc909830ffac3d926;hb=40ba69271b27beca78eb8e4dbc5b13c05100299a;hp=d62cda1091c8aebe3c1340c8ebf042d233077b8a;hpb=93c4b1bb3f9c9e3871d51b0fd52d935555df2521;p=vpp.git diff --git a/src/vat2/jsonconvert.c b/src/vat2/jsonconvert.c index d62cda1091c..1437b90688a 100644 --- a/src/vat2/jsonconvert.c +++ b/src/vat2/jsonconvert.c @@ -270,7 +270,8 @@ vl_api_ip4_address_t_fromjson (void **mp, int *len, cJSON *o, if (!p) return -1; unformat_init_string (&input, p, strlen(p)); - unformat(&input, "%U", unformat_ip4_address, a); + if (!unformat (&input, "%U", unformat_ip4_address, a)) + return -1; return 0; } @@ -283,7 +284,9 @@ vl_api_ip4_prefix_t_fromjson (void **mp, int *len, cJSON *o, if (!p) return -1; unformat_init_string (&input, p, strlen(p)); - unformat(&input, "%U/%d", unformat_ip4_address, &a->address, &a->len); + if (!unformat (&input, "%U/%d", unformat_ip4_address, &a->address, + &a->len)) + return -1; return 0; } @@ -302,7 +305,8 @@ vl_api_ip6_address_t_fromjson (void **mp, int *len, cJSON *o, if (!p) return -1; unformat_init_string (&input, p, strlen(p)); - unformat(&input, "%U", unformat_ip6_address, a); + if (!unformat (&input, "%U", unformat_ip6_address, a)) + return -1; return 0; } @@ -315,7 +319,8 @@ vl_api_ip6_prefix_t_fromjson (void **mp, int *len, cJSON *o, if (!p) return -1; unformat_init_string (&input, p, strlen(p)); - unformat(&input, "%U/%d", unformat_ip6_address, &a->address, &a->len); + if (!unformat (&input, "%U/%d", unformat_ip6_address, &a->address, &a->len)) + return -1; return 0; } @@ -408,7 +413,8 @@ vl_api_mac_address_t_fromjson (void **mp, int *len, cJSON *o, char *p = cJSON_GetStringValue(o); unformat_init_string (&input, p, strlen(p)); - unformat(&input, "%U", unformat_mac_address, a); + if (!unformat (&input, "%U", unformat_mac_address, a)) + return -1; return 0; } @@ -438,16 +444,6 @@ format_vl_api_interface_index_t (u8 *s, va_list *args) return format (s, "%u", *a); } -uword -unformat_vl_api_interface_index_t (unformat_input_t * input, va_list * args) -{ - u32 *a = va_arg (*args, u32 *); - - if (!unformat (input, "%u", a)) - return 0; - return 1; -} - void vl_api_string_cJSON_AddToObject(cJSON * const object, const char * const name, vl_api_string_t *astr) { @@ -505,24 +501,15 @@ uword unformat_vl_api_gbp_scope_t(unformat_input_t * input, va_list * args) cJSON * vl_api_ip4_address_with_prefix_t_tojson (vl_api_ip4_prefix_t *a) { - u8 *s = format(0, "%U", format_vl_api_ip4_address_t, a); - cJSON *o = cJSON_CreateString((char *)s); - vec_free(s); - return o; + return vl_api_ip4_prefix_t_tojson (a); } cJSON * vl_api_ip6_address_with_prefix_t_tojson (vl_api_ip6_prefix_t *a) { - u8 *s = format(0, "%U", format_vl_api_ip6_address_t, a); - cJSON *o = cJSON_CreateString((char *)s); - vec_free(s); - return o; + return vl_api_ip6_prefix_t_tojson (a); } cJSON * vl_api_address_with_prefix_t_tojson (vl_api_prefix_t *a) { - u8 *s = format(0, "%U", format_vl_api_address_t, a); - cJSON *o = cJSON_CreateString((char *)s); - vec_free(s); - return o; + return vl_api_prefix_t_tojson (a); } u8 * format_vl_api_mac_address_t (u8 * s, va_list * args)