Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
vat2: jsonconvert return checking - coverity
[vpp.git]
/
src
/
vat2
/
jsonconvert.c
diff --git
a/src/vat2/jsonconvert.c
b/src/vat2/jsonconvert.c
index
35279ee
..
645f7d4
100644
(file)
--- a/
src/vat2/jsonconvert.c
+++ b/
src/vat2/jsonconvert.c
@@
-42,7
+42,8
@@
int vl_api_u8_string_fromjson(cJSON *o, u8 *s, int len)
unformat_input_t input;
char *p = cJSON_GetStringValue(o);
unformat_init_string (&input, p, strlen(p));
unformat_input_t input;
char *p = cJSON_GetStringValue(o);
unformat_init_string (&input, p, strlen(p));
- unformat(&input, "0x%U", unformat_hex_string, s);
+ if (!unformat (&input, "0x%U", unformat_hex_string, s))
+ return -1;
return 0;
}
return 0;
}
@@
-59,7
+60,8
@@
u8string_fromjson(cJSON *o, char *fieldname)
char *p = cJSON_GetStringValue(item);
unformat_init_string (&input, p, strlen(p));
char *p = cJSON_GetStringValue(item);
unformat_init_string (&input, p, strlen(p));
- unformat(&input, "0x%U", unformat_hex_string, &s);
+ if (!unformat (&input, "0x%U", unformat_hex_string, &s))
+ return 0;
return s;
}
return s;
}
@@
-67,7
+69,8
@@
int
u8string_fromjson2(cJSON *o, char *fieldname, u8 *data)
{
u8 *s = u8string_fromjson(o, fieldname);
u8string_fromjson2(cJSON *o, char *fieldname, u8 *data)
{
u8 *s = u8string_fromjson(o, fieldname);
- if (!s) return 0;
+ if (!s)
+ return -1;
memcpy(data, s, vec_len(s));
vec_free(s);
return 0;
memcpy(data, s, vec_len(s));
vec_free(s);
return 0;
@@
-267,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));
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;
}
return 0;
}
@@
-280,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));
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;
}
return 0;
}
@@
-299,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));
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;
}
return 0;
}
@@
-312,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));
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;
}
return 0;
}
@@
-405,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));
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;
}
return 0;
}
@@
-435,16
+444,6
@@
format_vl_api_interface_index_t (u8 *s, va_list *args)
return format (s, "%u", *a);
}
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)
{
void
vl_api_string_cJSON_AddToObject(cJSON * const object, const char * const name, vl_api_string_t *astr)
{