diff --git a/blob.c b/blob.c index abcc9f2..fa86605 100644 --- a/blob.c +++ b/blob.c @@ -191,8 +191,7 @@ blob_nest_end(struct blob_buf *buf, void *cookie) static const size_t blob_type_minlen[BLOB_ATTR_LAST] = { [BLOB_ATTR_STRING] = 1, - [BLOB_ATTR_INT8] = sizeof(uint8_t), - [BLOB_ATTR_INT16] = sizeof(uint16_t), + [BLOB_ATTR_BOOL] = sizeof(bool), [BLOB_ATTR_INT32] = sizeof(uint32_t), [BLOB_ATTR_INT64] = sizeof(uint64_t), [BLOB_ATTR_DOUBLE] = sizeof(double), @@ -206,7 +205,7 @@ blob_check_type(const void *ptr, unsigned int len, int type) if (type >= BLOB_ATTR_LAST) return false; - if (type >= BLOB_ATTR_INT8 && type <= BLOB_ATTR_INT64) { + if (type >= BLOB_ATTR_BOOL && type <= BLOB_ATTR_INT64) { if (len != blob_type_minlen[type]) return false; } else { diff --git a/blob.h b/blob.h index 13bc7cc..a61a344 100644 --- a/blob.h +++ b/blob.h @@ -35,8 +35,8 @@ enum { BLOB_ATTR_NESTED, BLOB_ATTR_BINARY, BLOB_ATTR_STRING, - BLOB_ATTR_INT8, - BLOB_ATTR_INT16, + BLOB_ATTR_BOOL, + __BLOB_ATTR_DEPRECATED_INT16, BLOB_ATTR_INT32, BLOB_ATTR_INT64, BLOB_ATTR_DOUBLE, @@ -122,17 +122,10 @@ blob_pad_len(const struct blob_attr *attr) return len; } -static inline uint8_t -blob_get_u8(const struct blob_attr *attr) -{ - return *((uint8_t *) attr->data); -} - -static inline uint16_t -blob_get_u16(const struct blob_attr *attr) +static inline bool +blob_get_bool(const struct blob_attr *attr) { - uint16_t *tmp = (uint16_t*)attr->data; - return be16_to_cpu(*tmp); + return *((bool *) attr->data); } static inline uint32_t @@ -151,17 +144,8 @@ blob_get_u64(const struct blob_attr *attr) return tmp; } -static inline int8_t -blob_get_int8(const struct blob_attr *attr) -{ - return blob_get_u8(attr); -} - -static inline int16_t -blob_get_int16(const struct blob_attr *attr) -{ - return blob_get_u16(attr); -} +#define blob_get_u8 blob_get_bool +#define blob_get_u16 blob_get_u32 static inline int32_t blob_get_int32(const struct blob_attr *attr) @@ -181,6 +165,9 @@ blob_get_string(const struct blob_attr *attr) return attr->data; } +#define blob_get_int8 blob_get_bool +#define blob_get_int16 blob_get_int32 + static inline struct blob_attr * blob_next(const struct blob_attr *attr) { @@ -210,15 +197,8 @@ blob_put_string(struct blob_buf *buf, int id, const char *str) } static inline struct blob_attr * -blob_put_u8(struct blob_buf *buf, int id, uint8_t val) -{ - return blob_put(buf, id, &val, sizeof(val)); -} - -static inline struct blob_attr * -blob_put_u16(struct blob_buf *buf, int id, uint16_t val) +blob_put_bool(struct blob_buf *buf, int id, bool val) { - val = cpu_to_be16(val); return blob_put(buf, id, &val, sizeof(val)); } @@ -236,8 +216,8 @@ blob_put_u64(struct blob_buf *buf, int id, uint64_t val) return blob_put(buf, id, &val, sizeof(val)); } -#define blob_put_int8 blob_put_u8 -#define blob_put_int16 blob_put_u16 +#define blob_put_int8 blob_put_bool +#define blob_put_int16 blob_put_u32 #define blob_put_int32 blob_put_u32 #define blob_put_int64 blob_put_u64 diff --git a/blobmsg.c b/blobmsg.c index d87d607..8502491 100644 --- a/blobmsg.c +++ b/blobmsg.c @@ -16,8 +16,7 @@ #include "blobmsg.h" static const int blob_type[__BLOBMSG_TYPE_LAST] = { - [BLOBMSG_TYPE_INT8] = BLOB_ATTR_INT8, - [BLOBMSG_TYPE_INT16] = BLOB_ATTR_INT16, + [BLOBMSG_TYPE_BOOL] = BLOB_ATTR_BOOL, [BLOBMSG_TYPE_INT32] = BLOB_ATTR_INT32, [BLOBMSG_TYPE_INT64] = BLOB_ATTR_INT64, [BLOBMSG_TYPE_DOUBLE] = BLOB_ATTR_DOUBLE, @@ -202,8 +201,7 @@ int blobmsg_parse(const struct blobmsg_policy *policy, int policy_len, if (policy[i].type == BLOBMSG_CAST_INT64 && (blob_id(attr) != BLOBMSG_TYPE_INT64 && blob_id(attr) != BLOBMSG_TYPE_INT32 && - blob_id(attr) != BLOBMSG_TYPE_INT16 && - blob_id(attr) != BLOBMSG_TYPE_INT8)) + blob_id(attr) != BLOBMSG_TYPE_BOOL)) continue; if (blobmsg_namelen(hdr) != pslen[i]) diff --git a/blobmsg.h b/blobmsg.h index f2fc0d0..7c3e82c 100644 --- a/blobmsg.h +++ b/blobmsg.h @@ -29,9 +29,8 @@ enum blobmsg_type { BLOBMSG_TYPE_STRING, BLOBMSG_TYPE_INT64, BLOBMSG_TYPE_INT32, - BLOBMSG_TYPE_INT16, - BLOBMSG_TYPE_INT8, - BLOBMSG_TYPE_BOOL = BLOBMSG_TYPE_INT8, + __BLOBMSG_TYPE_DEPRECATED_INT16, + BLOBMSG_TYPE_BOOL, BLOBMSG_TYPE_DOUBLE, __BLOBMSG_TYPE_LAST, BLOBMSG_TYPE_LAST = __BLOBMSG_TYPE_LAST - 1, @@ -205,16 +204,9 @@ blobmsg_add_double(struct blob_buf *buf, const char *name, double val) } static inline int -blobmsg_add_u8(struct blob_buf *buf, const char *name, uint8_t val) +blobmsg_add_bool(struct blob_buf *buf, const char *name, bool val) { - return blobmsg_add_field(buf, BLOBMSG_TYPE_INT8, name, &val, 1); -} - -static inline int -blobmsg_add_u16(struct blob_buf *buf, const char *name, uint16_t val) -{ - val = cpu_to_be16(val); - return blobmsg_add_field(buf, BLOBMSG_TYPE_INT16, name, &val, 2); + return blobmsg_add_field(buf, BLOBMSG_TYPE_BOOL, name, &val, 1); } static inline int @@ -244,6 +236,9 @@ blobmsg_add_blob(struct blob_buf *buf, struct blob_attr *attr) blobmsg_data(attr), blobmsg_data_len(attr)); } +#define blobmsg_add_u8 blobmsg_add_bool +#define blobmsg_add_u16 blobmsg_add_u32 + void *blobmsg_open_nested(struct blob_buf *buf, const char *name, bool array); static inline void * @@ -275,21 +270,11 @@ static inline int blobmsg_buf_init(struct blob_buf *buf) return blob_buf_init(buf, BLOBMSG_TYPE_TABLE); } -static inline uint8_t blobmsg_get_u8(struct blob_attr *attr) -{ - return *(uint8_t *) blobmsg_data(attr); -} - static inline bool blobmsg_get_bool(struct blob_attr *attr) { return *(uint8_t *) blobmsg_data(attr); } -static inline uint16_t blobmsg_get_u16(struct blob_attr *attr) -{ - return be16_to_cpu(*(uint16_t *) blobmsg_data(attr)); -} - static inline uint32_t blobmsg_get_u32(struct blob_attr *attr) { return be32_to_cpu(*(uint32_t *) blobmsg_data(attr)); @@ -303,6 +288,9 @@ static inline uint64_t blobmsg_get_u64(struct blob_attr *attr) return tmp; } +#define blobmsg_get_u8 blobmsg_get_bool +#define blobmsg_get_u16 blobmsg_get_u32 + static inline uint64_t blobmsg_cast_u64(struct blob_attr *attr) { uint64_t tmp = 0; @@ -311,10 +299,6 @@ static inline uint64_t blobmsg_cast_u64(struct blob_attr *attr) tmp = blobmsg_get_u64(attr); else if (blobmsg_type(attr) == BLOBMSG_TYPE_INT32) tmp = blobmsg_get_u32(attr); - else if (blobmsg_type(attr) == BLOBMSG_TYPE_INT16) - tmp = blobmsg_get_u16(attr); - else if (blobmsg_type(attr) == BLOBMSG_TYPE_INT8) - tmp = blobmsg_get_u8(attr); return tmp; } @@ -327,10 +311,6 @@ static inline int64_t blobmsg_cast_s64(struct blob_attr *attr) tmp = blobmsg_get_u64(attr); else if (blobmsg_type(attr) == BLOBMSG_TYPE_INT32) tmp = (int32_t)blobmsg_get_u32(attr); - else if (blobmsg_type(attr) == BLOBMSG_TYPE_INT16) - tmp = (int16_t)blobmsg_get_u16(attr); - else if (blobmsg_type(attr) == BLOBMSG_TYPE_INT8) - tmp = (int8_t)blobmsg_get_u8(attr); return tmp; } diff --git a/blobmsg_json.c b/blobmsg_json.c index 31eec09..f42762f 100644 --- a/blobmsg_json.c +++ b/blobmsg_json.c @@ -60,7 +60,7 @@ bool blobmsg_add_json_element(struct blob_buf *b, const char *name, json_object blobmsg_add_string(b, name, json_object_get_string(obj)); break; case json_type_boolean: - blobmsg_add_u8(b, name, json_object_get_boolean(obj)); + blobmsg_add_bool(b, name, json_object_get_boolean(obj)); break; case json_type_int: { int64_t i64 = json_object_get_int64(obj); @@ -248,10 +248,7 @@ static void blobmsg_format_element(struct strbuf *s, struct blob_attr *attr, boo snprintf(buf, sizeof(buf), "null"); break; case BLOBMSG_TYPE_BOOL: - snprintf(buf, sizeof(buf), "%s", *(uint8_t *)data ? "true" : "false"); - break; - case BLOBMSG_TYPE_INT16: - snprintf(buf, sizeof(buf), "%" PRId16, (int16_t) be16_to_cpu(*(uint16_t *)data)); + snprintf(buf, sizeof(buf), "%s", *(bool *)data ? "true" : "false"); break; case BLOBMSG_TYPE_INT32: snprintf(buf, sizeof(buf), "%" PRId32, (int32_t) be32_to_cpu(*(uint32_t *)data)); diff --git a/tests/cram/test_blobmsg.t b/tests/cram/test_blobmsg.t index 0c192c5..e76cdbf 100644 --- a/tests/cram/test_blobmsg.t +++ b/tests/cram/test_blobmsg.t @@ -7,11 +7,7 @@ check that blobmsg is producing expected results: Message: Hello, world! List: { 0 (i8) - 100 (i8) - -128 (i8) - 127 (i8) - -32768 (i16) - 32767 (i16) + 1 (i8) -2147483648 (i32) 2147483647 (i32) -9223372036854775808 (i64) @@ -22,12 +18,8 @@ check that blobmsg is producing expected results: Testdata: { \tdbl-min : 0.000000 (dbl) (esc) \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc) - \tfoo : 0 (i8) (esc) - \tpoo : 100 (i8) (esc) - \tmoo-min : -128 (i8) (esc) - \tmoo-max : 127 (i8) (esc) - \tbar-min : -32768 (i16) (esc) - \tbar-max : 32767 (i16) (esc) + \tbool-min : 0 (i8) (esc) + \tbool-max : 1 (i8) (esc) \tbaz-min : -2147483648 (i32) (esc) \tbaz-max : 2147483647 (i32) (esc) \ttaz-min : -9223372036854775808 (i64) (esc) @@ -35,17 +27,13 @@ check that blobmsg is producing expected results: \tworld : 2 (str) (esc) } - [*] blobmsg to json: {"message":"Hello, world!","testdata":{"dbl-min":0.000000,"dbl-max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"foo":false,"poo":true,"moo-min":true,"moo-max":true,"bar-min":-32768,"bar-max":32767,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,true,true,-32768,32767,-2147483648,2147483647,-9223372036854775808,9223372036854775807,0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]} + [*] blobmsg to json: {"message":"Hello, world!","testdata":{"dbl-min":0.000000,"dbl-max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"bool-min":false,"bool-max":true,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,-2147483648,2147483647,-9223372036854775808,9223372036854775807,0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]} [*] blobmsg from json: Message: Hello, world! List: { 0 (i8) 1 (i8) - 1 (i8) - 1 (i8) - -32768 (i32) - 32767 (i32) -2147483648 (i32) 2147483647 (i32) -9223372036854775808 (i64) @@ -56,12 +44,8 @@ check that blobmsg is producing expected results: Testdata: { \tdbl-min : 0.000000 (dbl) (esc) \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc) - \tfoo : 0 (i8) (esc) - \tpoo : 1 (i8) (esc) - \tmoo-min : 1 (i8) (esc) - \tmoo-max : 1 (i8) (esc) - \tbar-min : -32768 (i32) (esc) - \tbar-max : 32767 (i32) (esc) + \tbool-min : 0 (i8) (esc) + \tbool-max : 1 (i8) (esc) \tbaz-min : -2147483648 (i32) (esc) \tbaz-max : 2147483647 (i32) (esc) \ttaz-min : -9223372036854775808 (i64) (esc) @@ -74,11 +58,7 @@ check that blobmsg is producing expected results: Message: Hello, world! List: { 0 (i8) - 100 (i8) - -128 (i8) - 127 (i8) - -32768 (i16) - 32767 (i16) + 1 (i8) -2147483648 (i32) 2147483647 (i32) -9223372036854775808 (i64) @@ -89,12 +69,8 @@ check that blobmsg is producing expected results: Testdata: { \tdbl-min : 0.000000 (dbl) (esc) \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc) - \tfoo : 0 (i8) (esc) - \tpoo : 100 (i8) (esc) - \tmoo-min : -128 (i8) (esc) - \tmoo-max : 127 (i8) (esc) - \tbar-min : -32768 (i16) (esc) - \tbar-max : 32767 (i16) (esc) + \tbool-min : 0 (i8) (esc) + \tbool-max : 1 (i8) (esc) \tbaz-min : -2147483648 (i32) (esc) \tbaz-max : 2147483647 (i32) (esc) \ttaz-min : -9223372036854775808 (i64) (esc) @@ -102,17 +78,13 @@ check that blobmsg is producing expected results: \tworld : 2 (str) (esc) } - [*] blobmsg to json: {"message":"Hello, world!","testdata":{"dbl-min":0.000000,"dbl-max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"foo":false,"poo":true,"moo-min":true,"moo-max":true,"bar-min":-32768,"bar-max":32767,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,true,true,-32768,32767,-2147483648,2147483647,-9223372036854775808,9223372036854775807,0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]} + [*] blobmsg to json: {"message":"Hello, world!","testdata":{"dbl-min":0.000000,"dbl-max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"bool-min":false,"bool-max":true,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,-2147483648,2147483647,-9223372036854775808,9223372036854775807,0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]} [*] blobmsg from json: Message: Hello, world! List: { 0 (i8) 1 (i8) - 1 (i8) - 1 (i8) - -32768 (i32) - 32767 (i32) -2147483648 (i32) 2147483647 (i32) -9223372036854775808 (i64) @@ -123,12 +95,8 @@ check that blobmsg is producing expected results: Testdata: { \tdbl-min : 0.000000 (dbl) (esc) \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc) - \tfoo : 0 (i8) (esc) - \tpoo : 1 (i8) (esc) - \tmoo-min : 1 (i8) (esc) - \tmoo-max : 1 (i8) (esc) - \tbar-min : -32768 (i32) (esc) - \tbar-max : 32767 (i32) (esc) + \tbool-min : 0 (i8) (esc) + \tbool-max : 1 (i8) (esc) \tbaz-min : -2147483648 (i32) (esc) \tbaz-max : 2147483647 (i32) (esc) \ttaz-min : -9223372036854775808 (i64) (esc) @@ -141,11 +109,7 @@ check that blobmsg is producing expected results: Message: Hello, world! List: { 0 (i8) - 100 (i8) - -128 (i8) - 127 (i8) - -32768 (i16) - 32767 (i16) + 1 (i8) -2147483648 (i32) 2147483647 (i32) -9223372036854775808 (i64) @@ -156,12 +120,8 @@ check that blobmsg is producing expected results: Testdata: { \tdbl-min : 0.000000 (dbl) (esc) \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc) - \tfoo : 0 (i8) (esc) - \tpoo : 100 (i8) (esc) - \tmoo-min : -128 (i8) (esc) - \tmoo-max : 127 (i8) (esc) - \tbar-min : -32768 (i16) (esc) - \tbar-max : 32767 (i16) (esc) + \tbool-min : 0 (i8) (esc) + \tbool-max : 1 (i8) (esc) \tbaz-min : -2147483648 (i32) (esc) \tbaz-max : 2147483647 (i32) (esc) \ttaz-min : -9223372036854775808 (i64) (esc) @@ -169,17 +129,13 @@ check that blobmsg is producing expected results: \tworld : 2 (str) (esc) } - [*] blobmsg to json: {"message":"Hello, world!","testdata":{"dbl-min":0.000000,"dbl-max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"foo":false,"poo":true,"moo-min":true,"moo-max":true,"bar-min":-32768,"bar-max":32767,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,true,true,-32768,32767,-2147483648,2147483647,-9223372036854775808,9223372036854775807,0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]} + [*] blobmsg to json: {"message":"Hello, world!","testdata":{"dbl-min":0.000000,"dbl-max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"bool-min":false,"bool-max":true,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,-2147483648,2147483647,-9223372036854775808,9223372036854775807,0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]} [*] blobmsg from json: Message: Hello, world! List: { 0 (i8) 1 (i8) - 1 (i8) - 1 (i8) - -32768 (i32) - 32767 (i32) -2147483648 (i32) 2147483647 (i32) -9223372036854775808 (i64) @@ -190,12 +146,8 @@ check that blobmsg is producing expected results: Testdata: { \tdbl-min : 0.000000 (dbl) (esc) \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc) - \tfoo : 0 (i8) (esc) - \tpoo : 1 (i8) (esc) - \tmoo-min : 1 (i8) (esc) - \tmoo-max : 1 (i8) (esc) - \tbar-min : -32768 (i32) (esc) - \tbar-max : 32767 (i32) (esc) + \tbool-min : 0 (i8) (esc) + \tbool-max : 1 (i8) (esc) \tbaz-min : -2147483648 (i32) (esc) \tbaz-max : 2147483647 (i32) (esc) \ttaz-min : -9223372036854775808 (i64) (esc) @@ -208,11 +160,7 @@ check that blobmsg is producing expected results: Message: Hello, world! List: { 0 (i8) - 100 (i8) - -128 (i8) - 127 (i8) - -32768 (i16) - 32767 (i16) + 1 (i8) -2147483648 (i32) 2147483647 (i32) -9223372036854775808 (i64) @@ -223,12 +171,8 @@ check that blobmsg is producing expected results: Testdata: { \tdbl-min : 0.000000 (dbl) (esc) \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc) - \tfoo : 0 (i8) (esc) - \tpoo : 100 (i8) (esc) - \tmoo-min : -128 (i8) (esc) - \tmoo-max : 127 (i8) (esc) - \tbar-min : -32768 (i16) (esc) - \tbar-max : 32767 (i16) (esc) + \tbool-min : 0 (i8) (esc) + \tbool-max : 1 (i8) (esc) \tbaz-min : -2147483648 (i32) (esc) \tbaz-max : 2147483647 (i32) (esc) \ttaz-min : -9223372036854775808 (i64) (esc) @@ -236,17 +180,13 @@ check that blobmsg is producing expected results: \tworld : 2 (str) (esc) } - [*] blobmsg to json: {"message":"Hello, world!","testdata":{"dbl-min":0.000000,"dbl-max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"foo":false,"poo":true,"moo-min":true,"moo-max":true,"bar-min":-32768,"bar-max":32767,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,true,true,-32768,32767,-2147483648,2147483647,-9223372036854775808,9223372036854775807,0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]} + [*] blobmsg to json: {"message":"Hello, world!","testdata":{"dbl-min":0.000000,"dbl-max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"bool-min":false,"bool-max":true,"baz-min":-2147483648,"baz-max":2147483647,"taz-min":-9223372036854775808,"taz-max":9223372036854775807,"world":"2"},"list":[false,true,-2147483648,2147483647,-9223372036854775808,9223372036854775807,0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000]} [*] blobmsg from json: Message: Hello, world! List: { 0 (i8) 1 (i8) - 1 (i8) - 1 (i8) - -32768 (i32) - 32767 (i32) -2147483648 (i32) 2147483647 (i32) -9223372036854775808 (i64) @@ -257,12 +197,8 @@ check that blobmsg is producing expected results: Testdata: { \tdbl-min : 0.000000 (dbl) (esc) \tdbl-max : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000 (dbl) (esc) - \tfoo : 0 (i8) (esc) - \tpoo : 1 (i8) (esc) - \tmoo-min : 1 (i8) (esc) - \tmoo-max : 1 (i8) (esc) - \tbar-min : -32768 (i32) (esc) - \tbar-max : 32767 (i32) (esc) + \tbool-min : 0 (i8) (esc) + \tbool-max : 1 (i8) (esc) \tbaz-min : -2147483648 (i32) (esc) \tbaz-max : 2147483647 (i32) (esc) \ttaz-min : -9223372036854775808 (i64) (esc) diff --git a/tests/cram/test_blobmsg_types.t b/tests/cram/test_blobmsg_types.t index 190e1f2..3f5da4c 100644 --- a/tests/cram/test_blobmsg_types.t +++ b/tests/cram/test_blobmsg_types.t @@ -9,10 +9,8 @@ check that blobmsg is producing expected results: int64_min: -9223372036854775808 int32_max: 2147483647 int32_min: -2147483648 - int16_max: 32767 - int16_min: -32768 - int8_max: 127 - int8_min: -128 + bool_max: 1 + bool_min: 0 double_max: 1.797693e+308 double_min: 2.225074e-308 [*] blobmsg dump cast_u64: @@ -21,10 +19,8 @@ check that blobmsg is producing expected results: int64_min: 9223372036854775808 int32_max: 2147483647 int32_min: 2147483648 - int16_max: 32767 - int16_min: 32768 - int8_max: 127 - int8_min: 128 + bool_max: 1 + bool_min: 0 double_max: 1.797693e+308 double_min: 2.225074e-308 [*] blobmsg dump cast_s64: @@ -33,14 +29,12 @@ check that blobmsg is producing expected results: int64_min: -9223372036854775808 int32_max: 2147483647 int32_min: -2147483648 - int16_max: 32767 - int16_min: -32768 - int8_max: 127 - int8_min: -128 + bool_max: 1 + bool_min: 0 double_max: 1.797693e+308 double_min: 2.225074e-308 - [*] blobmsg to json: {"string":"Hello, world!","int64_max":9223372036854775807,"int64_min":-9223372036854775808,"int32_max":2147483647,"int32_min":-2147483648,"int16_max":32767,"int16_min":-32768,"int8_max":true,"int8_min":true,"double_max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"double_min":0.000000} + [*] blobmsg to json: {"string":"Hello, world!","int64_max":9223372036854775807,"int64_min":-9223372036854775808,"int32_max":2147483647,"int32_min":-2147483648,"bool_max":true,"bool_min":false,"double_max":179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000,"double_min":0.000000} [*] blobmsg from json: string: Hello, world! @@ -48,10 +42,8 @@ check that blobmsg is producing expected results: int64_min: -9223372036854775808 int32_max: 2147483647 int32_min: -2147483648 - int16_max: 32767 - int16_min: -32768 - int8_max: 1 - int8_min: 1 + bool_max: 1 + bool_min: 0 double_max: 1.797693e+308 double_min: 0.000000e+00 @@ -61,10 +53,8 @@ check that blobmsg is producing expected results: int64_min: 9223372036854775808 int32_max: 2147483647 int32_min: 2147483648 - int16_max: 32767 - int16_min: 4294934528 - int8_max: 1 - int8_min: 1 + bool_max: 1 + bool_min: 0 double_max: 1.797693e+308 double_min: 0.000000e+00 @@ -74,9 +64,7 @@ check that blobmsg is producing expected results: int64_min: -9223372036854775808 int32_max: 2147483647 int32_min: -2147483648 - int16_max: 32767 - int16_min: -32768 - int8_max: 1 - int8_min: 1 + bool_max: 1 + bool_min: 0 double_max: 1.797693e+308 double_min: 0.000000e+00 diff --git a/tests/fuzz/test-fuzz.c b/tests/fuzz/test-fuzz.c index 026a3fd..d6f50f8 100644 --- a/tests/fuzz/test-fuzz.c +++ b/tests/fuzz/test-fuzz.c @@ -24,8 +24,7 @@ static void fuzz_blobmsg_parse(const uint8_t *data, size_t size) BLOBMSG_TYPE_STRING, BLOBMSG_TYPE_INT64, BLOBMSG_TYPE_INT32, - BLOBMSG_TYPE_INT16, - BLOBMSG_TYPE_INT8, + BLOBMSG_TYPE_BOOL, BLOBMSG_TYPE_DOUBLE, BLOBMSG_TYPE_TROUBLE, }; @@ -65,8 +64,7 @@ static void fuzz_blob_parse(const uint8_t *data, size_t size) FOO_ATTR_NESTED, FOO_ATTR_BINARY, FOO_ATTR_STRING, - FOO_ATTR_INT8, - FOO_ATTR_INT16, + FOO_ATTR_BOOL, FOO_ATTR_INT32, FOO_ATTR_INT64, FOO_ATTR_DOUBLE, @@ -78,8 +76,7 @@ static void fuzz_blob_parse(const uint8_t *data, size_t size) [FOO_ATTR_NESTED] = { .type = BLOB_ATTR_NESTED }, [FOO_ATTR_BINARY] = { .type = BLOB_ATTR_BINARY }, [FOO_ATTR_STRING] = { .type = BLOB_ATTR_STRING }, - [FOO_ATTR_INT8] = { .type = BLOB_ATTR_INT8 }, - [FOO_ATTR_INT16] = { .type = BLOB_ATTR_INT16 }, + [FOO_ATTR_BOOL] = { .type = BLOB_ATTR_BOOL }, [FOO_ATTR_INT32] = { .type = BLOB_ATTR_INT32 }, [FOO_ATTR_INT64] = { .type = BLOB_ATTR_INT64 }, [FOO_ATTR_DOUBLE] = { .type = BLOB_ATTR_DOUBLE }, diff --git a/tests/test-blobmsg-types.c b/tests/test-blobmsg-types.c index 4d77a27..26f1fe8 100644 --- a/tests/test-blobmsg-types.c +++ b/tests/test-blobmsg-types.c @@ -13,10 +13,8 @@ enum { FOO_INT64_MIN, FOO_INT32_MAX, FOO_INT32_MIN, - FOO_INT16_MAX, - FOO_INT16_MIN, - FOO_INT8_MAX, - FOO_INT8_MIN, + FOO_BOOL_MAX, + FOO_BOOL_MIN, FOO_DOUBLE_MAX, FOO_DOUBLE_MIN, __FOO_MAX @@ -43,21 +41,13 @@ static const struct blobmsg_policy pol[] = { .name = "int32_min", .type = BLOBMSG_TYPE_INT32, }, - [FOO_INT16_MAX] = { - .name = "int16_max", - .type = BLOBMSG_TYPE_INT16, + [FOO_BOOL_MAX] = { + .name = "bool_max", + .type = BLOBMSG_TYPE_BOOL, }, - [FOO_INT16_MIN] = { - .name = "int16_min", - .type = BLOBMSG_TYPE_INT16, - }, - [FOO_INT8_MAX] = { - .name = "int8_max", - .type = BLOBMSG_TYPE_INT8, - }, - [FOO_INT8_MIN] = { - .name = "int8_min", - .type = BLOBMSG_TYPE_INT8, + [FOO_BOOL_MIN] = { + .name = "bool_min", + .type = BLOBMSG_TYPE_BOOL, }, [FOO_DOUBLE_MAX] = { .name = "double_max", @@ -90,21 +80,13 @@ static const struct blobmsg_policy pol_json[] = { .name = "int32_min", .type = BLOBMSG_TYPE_INT32, }, - [FOO_INT16_MAX] = { - .name = "int16_max", - .type = BLOBMSG_TYPE_INT32, - }, - [FOO_INT16_MIN] = { - .name = "int16_min", - .type = BLOBMSG_TYPE_INT32, - }, - [FOO_INT8_MAX] = { - .name = "int8_max", - .type = BLOBMSG_TYPE_INT8, + [FOO_BOOL_MAX] = { + .name = "bool_max", + .type = BLOBMSG_TYPE_BOOL, }, - [FOO_INT8_MIN] = { - .name = "int8_min", - .type = BLOBMSG_TYPE_INT8, + [FOO_BOOL_MIN] = { + .name = "bool_min", + .type = BLOBMSG_TYPE_BOOL, }, [FOO_DOUBLE_MAX] = { .name = "double_max", @@ -138,14 +120,10 @@ static void dump_message(struct blob_buf *buf) fprintf(stderr, "int32_max: %" PRId32 "\n", (int32_t)blobmsg_get_u32(tb[FOO_INT32_MAX])); if (tb[FOO_INT32_MIN]) fprintf(stderr, "int32_min: %" PRId32 "\n", (int32_t)blobmsg_get_u32(tb[FOO_INT32_MIN])); - if (tb[FOO_INT16_MAX]) - fprintf(stderr, "int16_max: %" PRId16 "\n", (int16_t)blobmsg_get_u16(tb[FOO_INT16_MAX])); - if (tb[FOO_INT16_MIN]) - fprintf(stderr, "int16_min: %" PRId16 "\n", (int16_t)blobmsg_get_u16(tb[FOO_INT16_MIN])); - if (tb[FOO_INT8_MAX]) - fprintf(stderr, "int8_max: %" PRId8 "\n", (int8_t)blobmsg_get_u8(tb[FOO_INT8_MAX])); - if (tb[FOO_INT8_MIN]) - fprintf(stderr, "int8_min: %" PRId8 "\n", (int8_t)blobmsg_get_u8(tb[FOO_INT8_MIN])); + if (tb[FOO_BOOL_MAX]) + fprintf(stderr, "bool_max: %" PRIu8 "\n", (int8_t)blobmsg_get_bool(tb[FOO_BOOL_MAX])); + if (tb[FOO_BOOL_MIN]) + fprintf(stderr, "bool_min: %" PRIu8 "\n", (int8_t)blobmsg_get_bool(tb[FOO_BOOL_MIN])); if (tb[FOO_DOUBLE_MAX]) fprintf(stderr, "double_max: %e\n", blobmsg_get_double(tb[FOO_DOUBLE_MAX])); if (tb[FOO_DOUBLE_MIN]) @@ -170,14 +148,10 @@ static void dump_message_cast_u64(struct blob_buf *buf) fprintf(stderr, "int32_max: %" PRIu64 "\n", blobmsg_cast_u64(tb[FOO_INT32_MAX])); if (tb[FOO_INT32_MIN]) fprintf(stderr, "int32_min: %" PRIu64 "\n", blobmsg_cast_u64(tb[FOO_INT32_MIN])); - if (tb[FOO_INT16_MAX]) - fprintf(stderr, "int16_max: %" PRIu64 "\n", blobmsg_cast_u64(tb[FOO_INT16_MAX])); - if (tb[FOO_INT16_MIN]) - fprintf(stderr, "int16_min: %" PRIu64 "\n", blobmsg_cast_u64(tb[FOO_INT16_MIN])); - if (tb[FOO_INT8_MAX]) - fprintf(stderr, "int8_max: %" PRIu64 "\n", blobmsg_cast_u64(tb[FOO_INT8_MAX])); - if (tb[FOO_INT8_MIN]) - fprintf(stderr, "int8_min: %" PRIu64 "\n", blobmsg_cast_u64(tb[FOO_INT8_MIN])); + if (tb[FOO_BOOL_MAX]) + fprintf(stderr, "bool_max: %" PRIu8 "\n", blobmsg_get_bool(tb[FOO_BOOL_MAX])); + if (tb[FOO_BOOL_MIN]) + fprintf(stderr, "bool_min: %" PRIu8 "\n", blobmsg_get_bool(tb[FOO_BOOL_MIN])); if (tb[FOO_DOUBLE_MAX]) fprintf(stderr, "double_max: %e\n", blobmsg_get_double(tb[FOO_DOUBLE_MAX])); if (tb[FOO_DOUBLE_MIN]) @@ -202,14 +176,10 @@ static void dump_message_cast_s64(struct blob_buf *buf) fprintf(stderr, "int32_max: %" PRId64 "\n", blobmsg_cast_s64(tb[FOO_INT32_MAX])); if (tb[FOO_INT32_MIN]) fprintf(stderr, "int32_min: %" PRId64 "\n", blobmsg_cast_s64(tb[FOO_INT32_MIN])); - if (tb[FOO_INT16_MAX]) - fprintf(stderr, "int16_max: %" PRId64 "\n", blobmsg_cast_s64(tb[FOO_INT16_MAX])); - if (tb[FOO_INT16_MIN]) - fprintf(stderr, "int16_min: %" PRId64 "\n", blobmsg_cast_s64(tb[FOO_INT16_MIN])); - if (tb[FOO_INT8_MAX]) - fprintf(stderr, "int8_max: %" PRId64 "\n", blobmsg_cast_s64(tb[FOO_INT8_MAX])); - if (tb[FOO_INT8_MIN]) - fprintf(stderr, "int8_min: %" PRId64 "\n", blobmsg_cast_s64(tb[FOO_INT8_MIN])); + if (tb[FOO_BOOL_MAX]) + fprintf(stderr, "bool_max: %" PRIu8 "\n", blobmsg_get_bool(tb[FOO_BOOL_MAX])); + if (tb[FOO_BOOL_MIN]) + fprintf(stderr, "bool_min: %" PRIu8 "\n", blobmsg_get_bool(tb[FOO_BOOL_MIN])); if (tb[FOO_DOUBLE_MAX]) fprintf(stderr, "double_max: %e\n", blobmsg_get_double(tb[FOO_DOUBLE_MAX])); if (tb[FOO_DOUBLE_MIN]) @@ -234,18 +204,10 @@ static void dump_message_json(struct blob_buf *buf) fprintf(stderr, "int32_max: %" PRId32 "\n", blobmsg_get_u32(tb[FOO_INT32_MAX])); if (tb[FOO_INT32_MIN]) fprintf(stderr, "int32_min: %" PRId32 "\n", blobmsg_get_u32(tb[FOO_INT32_MIN])); - /* u16 is unknown to json, retrieve as u32 */ - if (tb[FOO_INT16_MAX]) - fprintf(stderr, "int16_max: %" PRId32 "\n", blobmsg_get_u32(tb[FOO_INT16_MAX])); - /* u16 is unknown to json, retrieve as u32 */ - if (tb[FOO_INT16_MIN]) - fprintf(stderr, "int16_min: %" PRId32 "\n", blobmsg_get_u32(tb[FOO_INT16_MIN])); - /* u8 is converted to boolean (true: all values != 0/false: value 0) in json */ - if (tb[FOO_INT8_MAX]) - fprintf(stderr, "int8_max: %" PRId8 "\n", blobmsg_get_u8(tb[FOO_INT8_MAX])); - /* u8 is converted to boolean (true: all values != 0/false: value 0) in json */ - if (tb[FOO_INT8_MIN]) - fprintf(stderr, "int8_min: %" PRId8 "\n", blobmsg_get_u8(tb[FOO_INT8_MIN])); + if (tb[FOO_BOOL_MAX]) + fprintf(stderr, "bool_max: %" PRIu8 "\n", blobmsg_get_bool(tb[FOO_BOOL_MAX])); + if (tb[FOO_BOOL_MIN]) + fprintf(stderr, "bool_min: %" PRIu8 "\n", blobmsg_get_bool(tb[FOO_BOOL_MIN])); if (tb[FOO_DOUBLE_MAX]) fprintf(stderr, "double_max: %e\n", blobmsg_get_double(tb[FOO_DOUBLE_MAX])); if (tb[FOO_DOUBLE_MIN]) @@ -270,14 +232,10 @@ static void dump_message_cast_u64_json(struct blob_buf *buf) fprintf(stderr, "int32_max: %" PRIu64 "\n", blobmsg_cast_u64(tb[FOO_INT32_MAX])); if (tb[FOO_INT32_MIN]) fprintf(stderr, "int32_min: %" PRIu64 "\n", blobmsg_cast_u64(tb[FOO_INT32_MIN])); - if (tb[FOO_INT16_MAX]) - fprintf(stderr, "int16_max: %" PRIu64 "\n", blobmsg_cast_u64(tb[FOO_INT16_MAX])); - if (tb[FOO_INT16_MIN]) - fprintf(stderr, "int16_min: %" PRIu64 "\n", blobmsg_cast_u64(tb[FOO_INT16_MIN])); - if (tb[FOO_INT8_MAX]) - fprintf(stderr, "int8_max: %" PRIu64 "\n", blobmsg_cast_u64(tb[FOO_INT8_MAX])); - if (tb[FOO_INT8_MIN]) - fprintf(stderr, "int8_min: %" PRIu64 "\n", blobmsg_cast_u64(tb[FOO_INT8_MIN])); + if (tb[FOO_BOOL_MAX]) + fprintf(stderr, "bool_max: %" PRIu8 "\n", blobmsg_get_bool(tb[FOO_BOOL_MAX])); + if (tb[FOO_BOOL_MIN]) + fprintf(stderr, "bool_min: %" PRIu8 "\n", blobmsg_get_bool(tb[FOO_BOOL_MIN])); if (tb[FOO_DOUBLE_MAX]) fprintf(stderr, "double_max: %e\n", blobmsg_get_double(tb[FOO_DOUBLE_MAX])); if (tb[FOO_DOUBLE_MIN]) @@ -302,14 +260,10 @@ static void dump_message_cast_s64_json(struct blob_buf *buf) fprintf(stderr, "int32_max: %" PRId64 "\n", blobmsg_cast_s64(tb[FOO_INT32_MAX])); if (tb[FOO_INT32_MIN]) fprintf(stderr, "int32_min: %" PRId64 "\n", blobmsg_cast_s64(tb[FOO_INT32_MIN])); - if (tb[FOO_INT16_MAX]) - fprintf(stderr, "int16_max: %" PRId64 "\n", blobmsg_cast_s64(tb[FOO_INT16_MAX])); - if (tb[FOO_INT16_MIN]) - fprintf(stderr, "int16_min: %" PRId64 "\n", blobmsg_cast_s64(tb[FOO_INT16_MIN])); - if (tb[FOO_INT8_MAX]) - fprintf(stderr, "int8_max: %" PRId64 "\n", blobmsg_cast_s64(tb[FOO_INT8_MAX])); - if (tb[FOO_INT8_MIN]) - fprintf(stderr, "int8_min: %" PRId64 "\n", blobmsg_cast_s64(tb[FOO_INT8_MIN])); + if (tb[FOO_BOOL_MAX]) + fprintf(stderr, "bool_max: %" PRIu8 "\n", blobmsg_get_bool(tb[FOO_BOOL_MAX])); + if (tb[FOO_BOOL_MIN]) + fprintf(stderr, "bool_min: %" PRIu8 "\n", blobmsg_get_bool(tb[FOO_BOOL_MIN])); if (tb[FOO_DOUBLE_MAX]) fprintf(stderr, "double_max: %e\n", blobmsg_get_double(tb[FOO_DOUBLE_MAX])); if (tb[FOO_DOUBLE_MIN]) @@ -324,10 +278,8 @@ fill_message(struct blob_buf *buf) blobmsg_add_u64(buf, "int64_min", INT64_MIN); blobmsg_add_u32(buf, "int32_max", INT32_MAX); blobmsg_add_u32(buf, "int32_min", INT32_MIN); - blobmsg_add_u16(buf, "int16_max", INT16_MAX); - blobmsg_add_u16(buf, "int16_min", INT16_MIN); - blobmsg_add_u8(buf, "int8_max", INT8_MAX); - blobmsg_add_u8(buf, "int8_min", INT8_MIN); + blobmsg_add_bool(buf, "bool_max", true); + blobmsg_add_bool(buf, "bool_min", false); blobmsg_add_double(buf, "double_max", DBL_MAX); blobmsg_add_double(buf, "double_min", DBL_MIN); } diff --git a/tests/test-blobmsg.c b/tests/test-blobmsg.c index 2224853..c6b3aa5 100644 --- a/tests/test-blobmsg.c +++ b/tests/test-blobmsg.c @@ -40,11 +40,8 @@ static void dump_attr_data(struct blob_attr *data, int indent, int next_indent) case BLOBMSG_TYPE_STRING: indent_printf(indent, "%s (str)\n", blobmsg_get_string(data)); break; - case BLOBMSG_TYPE_INT8: - indent_printf(indent, "%d (i8)\n", (int8_t) blobmsg_get_u8(data)); - break; - case BLOBMSG_TYPE_INT16: - indent_printf(indent, "%d (i16)\n", (int16_t) blobmsg_get_u16(data)); + case BLOBMSG_TYPE_BOOL: + indent_printf(indent, "%d (i8)\n", (int8_t) blobmsg_get_bool(data)); break; case BLOBMSG_TYPE_INT32: indent_printf(indent, "%d (i32)\n", (int32_t) blobmsg_get_u32(data)); @@ -121,12 +118,8 @@ fill_message(struct blob_buf *buf) tbl = blobmsg_open_table(buf, "testdata"); blobmsg_add_double(buf, "dbl-min", DBL_MIN); blobmsg_add_double(buf, "dbl-max", DBL_MAX); - blobmsg_add_u8(buf, "foo", 0); - blobmsg_add_u8(buf, "poo", 100); - blobmsg_add_u8(buf, "moo-min", INT8_MIN); - blobmsg_add_u8(buf, "moo-max", INT8_MAX); - blobmsg_add_u16(buf, "bar-min", INT16_MIN); - blobmsg_add_u16(buf, "bar-max", INT16_MAX); + blobmsg_add_bool(buf, "bool-min", false); + blobmsg_add_bool(buf, "bool-max", true); blobmsg_add_u32(buf, "baz-min", INT32_MIN); blobmsg_add_u32(buf, "baz-max", INT32_MAX); blobmsg_add_u64(buf, "taz-min", INT64_MIN); @@ -135,12 +128,8 @@ fill_message(struct blob_buf *buf) blobmsg_close_table(buf, tbl); tbl = blobmsg_open_array(buf, "list"); - blobmsg_add_u8(buf, NULL, 0); - blobmsg_add_u8(buf, NULL, 100); - blobmsg_add_u8(buf, NULL, INT8_MIN); - blobmsg_add_u8(buf, NULL, INT8_MAX); - blobmsg_add_u16(buf, NULL, INT16_MIN); - blobmsg_add_u16(buf, NULL, INT16_MAX); + blobmsg_add_bool(buf, NULL, false); + blobmsg_add_bool(buf, NULL, true); blobmsg_add_u32(buf, NULL, INT32_MIN); blobmsg_add_u32(buf, NULL, INT32_MAX); blobmsg_add_u64(buf, NULL, INT64_MIN);