lib: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99 integer types. Jira: ZEP-2051 Change-Id: I74bc6384c4090f4ae322e3aa151874f583a5fe73 Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
3c454017b4
commit
9a74ee1730
2 changed files with 12 additions and 12 deletions
|
@ -387,7 +387,7 @@ static int arr_next(struct json_obj *json, struct token *value)
|
||||||
return element_token(value->type);
|
return element_token(value->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_num(const struct token *token, int32_t *num)
|
static int decode_num(const struct token *token, s32_t *num)
|
||||||
{
|
{
|
||||||
/* FIXME: strtod() is not available in newlib/minimal libc,
|
/* FIXME: strtod() is not available in newlib/minimal libc,
|
||||||
* so using strtol() here.
|
* so using strtol() here.
|
||||||
|
@ -456,7 +456,7 @@ static int decode_value(struct json_obj *obj,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case JSON_TOK_NUMBER: {
|
case JSON_TOK_NUMBER: {
|
||||||
int32_t *num = field;
|
s32_t *num = field;
|
||||||
|
|
||||||
return decode_num(value, num);
|
return decode_num(value, num);
|
||||||
}
|
}
|
||||||
|
@ -477,7 +477,7 @@ static ptrdiff_t get_elem_size(const struct json_obj_descr *descr)
|
||||||
{
|
{
|
||||||
switch (descr->type) {
|
switch (descr->type) {
|
||||||
case JSON_TOK_NUMBER:
|
case JSON_TOK_NUMBER:
|
||||||
return sizeof(int32_t);
|
return sizeof(s32_t);
|
||||||
case JSON_TOK_STRING:
|
case JSON_TOK_STRING:
|
||||||
return sizeof(char *);
|
return sizeof(char *);
|
||||||
case JSON_TOK_TRUE:
|
case JSON_TOK_TRUE:
|
||||||
|
@ -537,7 +537,7 @@ static int obj_parse(struct json_obj *obj, const struct json_obj_descr *descr,
|
||||||
size_t descr_len, void *val)
|
size_t descr_len, void *val)
|
||||||
{
|
{
|
||||||
struct json_obj_key_value kv;
|
struct json_obj_key_value kv;
|
||||||
int32_t decoded_fields = 0;
|
s32_t decoded_fields = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ int json_obj_parse(char *payload, size_t len,
|
||||||
return obj_parse(&obj, descr, descr_len, val);
|
return obj_parse(&obj, descr, descr_len, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t escape_as(uint8_t chr)
|
static u8_t escape_as(u8_t chr)
|
||||||
{
|
{
|
||||||
switch (chr) {
|
switch (chr) {
|
||||||
case '"':
|
case '"':
|
||||||
|
@ -626,10 +626,10 @@ static int json_escape_internal(const char *str,
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
for (cur = str; ret == 0 && *cur; cur++) {
|
for (cur = str; ret == 0 && *cur; cur++) {
|
||||||
uint8_t escaped = escape_as(*cur);
|
u8_t escaped = escape_as(*cur);
|
||||||
|
|
||||||
if (escaped) {
|
if (escaped) {
|
||||||
uint8_t bytes[2] = { '\\', escaped };
|
u8_t bytes[2] = { '\\', escaped };
|
||||||
|
|
||||||
ret = append_bytes(bytes, 2, data);
|
ret = append_bytes(bytes, 2, data);
|
||||||
} else {
|
} else {
|
||||||
|
@ -646,7 +646,7 @@ struct appender {
|
||||||
size_t size;
|
size_t size;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int append_bytes_to_buf(const uint8_t *bytes, size_t len, void *data)
|
static int append_bytes_to_buf(const u8_t *bytes, size_t len, void *data)
|
||||||
{
|
{
|
||||||
struct appender *appender = data;
|
struct appender *appender = data;
|
||||||
|
|
||||||
|
@ -772,10 +772,10 @@ static int str_encode(const char **str, json_append_bytes_t append_bytes,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int num_encode(const int32_t *num, json_append_bytes_t append_bytes,
|
static int num_encode(const s32_t *num, json_append_bytes_t append_bytes,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
char buf[3 * sizeof(int32_t)];
|
char buf[3 * sizeof(s32_t)];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = snprintk(buf, sizeof(buf), "%d", *num);
|
ret = snprintk(buf, sizeof(buf), "%d", *num);
|
||||||
|
@ -890,7 +890,7 @@ int json_obj_encode_buf(const struct json_obj_descr *descr, size_t descr_len,
|
||||||
&appender);
|
&appender);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int measure_bytes(const uint8_t *bytes, size_t len, void *data)
|
static int measure_bytes(const u8_t *bytes, size_t len, void *data)
|
||||||
{
|
{
|
||||||
ssize_t *total = data;
|
ssize_t *total = data;
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ struct json_obj_descr {
|
||||||
* error (which will be propagated to the return value of
|
* error (which will be propagated to the return value of
|
||||||
* json_obj_encode()), or 0 on success.
|
* json_obj_encode()), or 0 on success.
|
||||||
*/
|
*/
|
||||||
typedef int (*json_append_bytes_t)(const uint8_t *bytes, size_t len,
|
typedef int (*json_append_bytes_t)(const u8_t *bytes, size_t len,
|
||||||
void *data);
|
void *data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue