blobmsg: remove INT8 and INT16 types#25
Conversation
|
NACK. I'd prefer to just deprecate treating u8 as integer and deprecate using u16 in blobmsg entirely. That way we can avoid a lot of compatibility mess and JSON conversion issues. Due to padding, u8, u16 and u32 attributes have the same effective size anyway, so there isn't really a good reason to use them for integer values. |
So u8 always becomes boolean, and anything numeric should use u32? |
|
Yes. Either u32 or u64 (if bigger values are required). |
|
Ah. I see. Could you put a heads-up in the or a readme or somewhere appropriate for this, please? |
ubus coerces u8 to boolean, and one workaround suitable is to amend u8 values (despite them being and containing only a u8 int) to u32 values. ubus coerces u8 to booleans due to historical reasons. Any calls to e.g. ubus call odhcp6c.eth1 get_state (and subsequently downstream dependencies which use this invocation) return booleans(!) where there shall be a number. Amended calls to blobmsg_add_u8 into blobmsg_add_u32 to resolve this. Amended calls to blobmsg_add_u16 into blobmsg_add_u32 also. Apparently u8 and u16 get padded to u32 anyway. See @nbd168 openwrt/libubox#25 (comment) " I'd prefer to just deprecate treating u8 as integer and deprecate using u16 in blobmsg entirely. That way we can avoid a lot of compatibility mess and JSON conversion issues. Due to padding, u8, u16 and u32 attributes have the same effective size anyway, so there isn't really a good reason to use them for integer values. " Signed-off-by: Paul Donald <newtwen+github@gmail.com>
|
might need a transition shim since there are some downstream users of |
ubus coerces u8 to boolean, and one workaround suitable is to amend u8 values (despite them being and containing only a u8 int) to u32 values. ubus coerces u8 to booleans due to historical reasons. Any calls to e.g. ubus call odhcp6c.eth1 get_state (and subsequently downstream dependencies which use this invocation) return booleans(!) where there shall be a number. Amended calls to blobmsg_add_u8 into blobmsg_add_u32 to resolve this. Amended calls to blobmsg_add_u16 into blobmsg_add_u32 also. Apparently u8 and u16 get padded to u32 anyway. See @nbd168 openwrt/libubox#25 (comment) " I'd prefer to just deprecate treating u8 as integer and deprecate using u16 in blobmsg entirely. That way we can avoid a lot of compatibility mess and JSON conversion issues. Due to padding, u8, u16 and u32 attributes have the same effective size anyway, so there isn't really a good reason to use them for integer values. " Signed-off-by: Paul Donald <newtwen+github@gmail.com> Link: openwrt#117 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
u8 has the same effective size as u32 so we can remove it to avoid a lot of compatibility mess and JSON conversion issues. Link: openwrt#25 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
u16 has the same effective size as u32 so we can remove it to avoid a lot of compatibility mess and JSON conversion issues. Link: openwrt#25 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
u8 has the same effective size as u32 so we can remove it to avoid a lot of compatibility mess and JSON conversion issues. Link: openwrt#25 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
u16 has the same effective size as u32 so we can remove it to avoid a lot of compatibility mess and JSON conversion issues. Link: openwrt#25 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
u8 has the same effective size as u32 so we can remove it to avoid a lot of compatibility mess and JSON conversion issues. Link: openwrt#25 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
u16 has the same effective size as u32 so we can remove it to avoid a lot of compatibility mess and JSON conversion issues. Link: openwrt#25 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
u8 has the same effective size as u32 so we can remove it to avoid a lot of compatibility mess and JSON conversion issues. Link: openwrt#25 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
|
I'd prefer to just deprecate int8/int16 support without actually removing it. |
Add proper types for BOOL and INT8 instead of mixing them.
This allows using blobmsg_add_u8 for uint8_t without converting values to
true or false.
Note: I didn't have time to test it yet.
CC @Alphix @systemcrash