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:
authorPeter Seiderer <ps.report@gmx.net>2021-02-26 22:24:20 +0300
committerDaniel Golle <daniel@makrotopia.org>2021-03-02 15:06:24 +0300
commit2e52c7e9a90ab7ba1cf9d2986d1505ca5d184698 (patch)
treed3eb6904bff6a2054c78a355b34af80b82861f34
parent5bc0146a1d6474d339c4ade9a227f32cc27a8b93 (diff)
libubox: fix BLOBMSG_CAST_INT64 (do not override BLOBMSG_TYPE_DOUBLE)
Commit 9e52171 ('blobmsg: introduce BLOBMSG_CAST_INT64') broke blobmsg_parse() for BLOBMSG_TYPE_DOUBLE. This is because the enum definition leads to the following double define for BLOBMSG_CAST_INT64/BLOBMSG_TYPE_DOUBLE as value 8. Tested with: $ cat test-enum-001.c #include <stdio.h> enum blobmsg_type { BLOBMSG_TYPE_UNSPEC, BLOBMSG_TYPE_ARRAY, BLOBMSG_TYPE_TABLE, BLOBMSG_TYPE_STRING, BLOBMSG_TYPE_INT64, BLOBMSG_TYPE_INT32, BLOBMSG_TYPE_INT16, BLOBMSG_TYPE_INT8, BLOBMSG_TYPE_DOUBLE, __BLOBMSG_TYPE_LAST, BLOBMSG_TYPE_LAST = __BLOBMSG_TYPE_LAST - 1, BLOBMSG_TYPE_BOOL = BLOBMSG_TYPE_INT8, BLOBMSG_CAST_INT64, }; int main(int artc, char* argv[]) { printf("BLOBMSG_TYPE_UNSPEC: %d\n", BLOBMSG_TYPE_UNSPEC); printf("BLOBMSG_TYPE_ARRAY: %d\n", BLOBMSG_TYPE_ARRAY); printf("BLOBMSG_TYPE_TABLE: %d\n", BLOBMSG_TYPE_TABLE); printf("BLOBMSG_TYPE_STRING: %d\n", BLOBMSG_TYPE_STRING); printf("BLOBMSG_TYPE_INT64: %d\n", BLOBMSG_TYPE_INT64); printf("BLOBMSG_TYPE_INT32: %d\n", BLOBMSG_TYPE_INT32); printf("BLOBMSG_TYPE_INT16: %d\n", BLOBMSG_TYPE_INT16); printf("BLOBMSG_TYPE_INT8: %d\n", BLOBMSG_TYPE_INT8); printf("BLOBMSG_TYPE_DOUBLE: %d\n", BLOBMSG_TYPE_DOUBLE); printf("__BLOBMSG_TYPE_LAST: %d\n", __BLOBMSG_TYPE_LAST); printf("BLOBMSG_TYPE_LAST: %d\n", BLOBMSG_TYPE_LAST); printf("BLOBMSG_TYPE_BOOL: %d\n", BLOBMSG_TYPE_BOOL); printf("BLOBMSG_CAST_INT64: %d\n", BLOBMSG_CAST_INT64); return 0; } $ gcc test-enum-001.c $ ./a.out BLOBMSG_TYPE_UNSPEC: 0 BLOBMSG_TYPE_ARRAY: 1 BLOBMSG_TYPE_TABLE: 2 BLOBMSG_TYPE_STRING: 3 BLOBMSG_TYPE_INT64: 4 BLOBMSG_TYPE_INT32: 5 BLOBMSG_TYPE_INT16: 6 BLOBMSG_TYPE_INT8: 7 BLOBMSG_TYPE_DOUBLE: 8 __BLOBMSG_TYPE_LAST: 9 BLOBMSG_TYPE_LAST: 8 BLOBMSG_TYPE_BOOL: 7 BLOBMSG_CAST_INT64: 8 Fix this by changing the enum defintion to assign BLOBMSG_CAST_INT64 to the unique value 9. Signed-off-by: Peter Seiderer <ps.report@gmx.net>
-rw-r--r--blobmsg.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/blobmsg.h b/blobmsg.h
index 4a151c7..1f0634d 100644
--- a/blobmsg.h
+++ b/blobmsg.h
@@ -31,11 +31,11 @@ enum blobmsg_type {
BLOBMSG_TYPE_INT32,
BLOBMSG_TYPE_INT16,
BLOBMSG_TYPE_INT8,
+ BLOBMSG_TYPE_BOOL = BLOBMSG_TYPE_INT8,
BLOBMSG_TYPE_DOUBLE,
__BLOBMSG_TYPE_LAST,
BLOBMSG_TYPE_LAST = __BLOBMSG_TYPE_LAST - 1,
- BLOBMSG_TYPE_BOOL = BLOBMSG_TYPE_INT8,
- BLOBMSG_CAST_INT64,
+ BLOBMSG_CAST_INT64 = __BLOBMSG_TYPE_LAST,
};
struct blobmsg_hdr {