projects
/
project
/
libubox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove int16, use int8 as bool instead of integer
[project/libubox.git]
/
blobmsg_json.c
diff --git
a/blobmsg_json.c
b/blobmsg_json.c
index
896a9c2
..
eae2ac8
100644
(file)
--- a/
blobmsg_json.c
+++ b/
blobmsg_json.c
@@
-180,6
+180,9
@@
static void blobmsg_format_element(struct strbuf *s, struct blob_attr *attr, boo
void *data;
int len;
void *data;
int len;
+ if (!blobmsg_check_attr(attr, false))
+ return;
+
if (!array && blobmsg_name(attr)[0]) {
blobmsg_format_string(s, blobmsg_name(attr));
blobmsg_puts(s, ":", 1);
if (!array && blobmsg_name(attr)[0]) {
blobmsg_format_string(s, blobmsg_name(attr));
blobmsg_puts(s, ":", 1);
@@
-201,16
+204,13
@@
static void blobmsg_format_element(struct strbuf *s, struct blob_attr *attr, boo
data_str = buf;
switch(blob_id(attr)) {
case BLOBMSG_TYPE_INT8:
data_str = buf;
switch(blob_id(attr)) {
case BLOBMSG_TYPE_INT8:
- sprintf(buf, "%d", *(uint8_t *)data);
- break;
- case BLOBMSG_TYPE_INT16:
- sprintf(buf, "%d", *(uint16_t *)data);
+ sprintf(buf, "%s", *(uint8_t *)data ? "true" : "false");
break;
case BLOBMSG_TYPE_INT32:
sprintf(buf, "%d", *(uint32_t *)data);
break;
case BLOBMSG_TYPE_INT64:
break;
case BLOBMSG_TYPE_INT32:
sprintf(buf, "%d", *(uint32_t *)data);
break;
case BLOBMSG_TYPE_INT64:
- sprintf(buf, "%lld", *(uint64_t *)data);
+ sprintf(buf, "%lld",
(long long int)
*(uint64_t *)data);
break;
case BLOBMSG_TYPE_STRING:
blobmsg_format_string(s, data);
break;
case BLOBMSG_TYPE_STRING:
blobmsg_format_string(s, data);
@@
-263,5
+263,7
@@
char *blobmsg_format_json_with_cb(struct blob_attr *attr, bool list, blobmsg_jso
return NULL;
s.buf = realloc(s.buf, s.pos + 1);
return NULL;
s.buf = realloc(s.buf, s.pos + 1);
+ s.buf[s.pos] = 0;
+
return s.buf;
}
return s.buf;
}