Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Štetiar <ynezz@true.cz>2020-01-13 00:40:18 +0300
committerPetr Štetiar <ynezz@true.cz>2020-01-20 18:15:34 +0300
commitf0da3a4283b7d1192de5c7e620df9381cd5a724b (patch)
tree1ed2370925a996b59d3f9701881517a61f00f3e6 /blobmsg_json.c
parent20a070f0813972a16b7d01586beced58a0828742 (diff)
blobmsg_json: fix int16 serialization
int16 blobmsg type is currently being serialized as uint16_t due to missing cast during JSON output. Following blobmsg content: bar-min: -32768 (i16) bar-max: 32767 (i16) Produces following JSON: { "bar-min":32768,"bar-max":32767 } Whereas one would expect: { "bar-min":-32768,"bar-max":32767 } Reviewed-by: Jo-Philipp Wich <jo@mein.io> Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'blobmsg_json.c')
-rw-r--r--blobmsg_json.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/blobmsg_json.c b/blobmsg_json.c
index 1859211..aee7a64 100644
--- a/blobmsg_json.c
+++ b/blobmsg_json.c
@@ -249,7 +249,7 @@ static void blobmsg_format_element(struct strbuf *s, struct blob_attr *attr, boo
sprintf(buf, "%s", *(uint8_t *)data ? "true" : "false");
break;
case BLOBMSG_TYPE_INT16:
- sprintf(buf, "%d", be16_to_cpu(*(uint16_t *)data));
+ sprintf(buf, "%d", (int16_t) be16_to_cpu(*(uint16_t *)data));
break;
case BLOBMSG_TYPE_INT32:
sprintf(buf, "%d", (int32_t) be32_to_cpu(*(uint32_t *)data));