-
Notifications
You must be signed in to change notification settings - Fork 28
blobmsg: remove INT8 and INT16 types #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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 <[email protected]>
|
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 <[email protected]> Link: openwrt#117 Signed-off-by: Álvaro Fernández Rojas <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
|
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