X-Git-Url: http://git.archive.openwrt.org/?p=project%2Flibubox.git;a=blobdiff_plain;f=blobmsg_json.c;h=e4e005fdf979450724ef1620fc52ad90d62d2f16;hp=7a4ab7b15661bfcd2a8e63b30112e70ca8332652;hb=a34c8f6918c291275ded2b6fd9b94ac91722ded2;hpb=54a0b49326904fc3281c72cd9d9f1fe950e39d05 diff --git a/blobmsg_json.c b/blobmsg_json.c index 7a4ab7b..e4e005f 100644 --- a/blobmsg_json.c +++ b/blobmsg_json.c @@ -151,11 +151,12 @@ static void add_separator(struct strbuf *s) static void blobmsg_format_string(struct strbuf *s, const char *str) { - const char *p, *last = str, *end = str + strlen(str); + const unsigned char *p, *last, *end; char buf[8] = "\\u00"; + end = (unsigned char *) str + strlen(str); blobmsg_puts(s, "\"", 1); - for (p = str; *p; p++) { + for (p = (unsigned char *) str, last = p; *p; p++) { char escape = '\0'; int len; @@ -187,20 +188,20 @@ static void blobmsg_format_string(struct strbuf *s, const char *str) continue; if (p > last) - blobmsg_puts(s, last, p - last); + blobmsg_puts(s, (char *) last, p - last); last = p + 1; buf[1] = escape; if (escape == 'u') { sprintf(buf + 4, "%02x", (unsigned char) *p); - len = 4; + len = 6; } else { len = 2; } blobmsg_puts(s, buf, len); } - blobmsg_puts(s, last, end - last); + blobmsg_puts(s, (char *) last, end - last); blobmsg_puts(s, "\"", 1); } @@ -246,7 +247,7 @@ static void blobmsg_format_element(struct strbuf *s, struct blob_attr *attr, boo sprintf(buf, "%d", be16_to_cpu(*(uint16_t *)data)); break; case BLOBMSG_TYPE_INT32: - sprintf(buf, "%d", be32_to_cpu(*(uint32_t *)data)); + sprintf(buf, "%d", (int32_t) be32_to_cpu(*(uint32_t *)data)); break; case BLOBMSG_TYPE_INT64: sprintf(buf, "%lld", (long long int) be64_to_cpu(*(uint64_t *)data));