Skip to content

blob: deprecate int8 and int16#28

Open
Noltari wants to merge 2 commits into
openwrt:masterfrom
Noltari:deprecate-int8-int16
Open

blob: deprecate int8 and int16#28
Noltari wants to merge 2 commits into
openwrt:masterfrom
Noltari:deprecate-int8-int16

Conversation

@Noltari
Copy link
Copy Markdown
Member

@Noltari Noltari commented Nov 13, 2025

  • blob: add missing boolean functions
  • blob: deprecate u8 and u16

Ping @nbd168 @systemcrash @Alphix

@Noltari Noltari requested a review from nbd168 November 13, 2025 10:16
Comment thread blob.h Outdated
Comment on lines 125 to 128
static inline uint8_t
blob_get_u8(const struct blob_attr *attr)
blob_get_bool(const struct blob_attr *attr)
{
return *((uint8_t *) attr->data);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be:

static inline bool
blob_get_bool(const struct blob_attr *attr)
{
    return *((uint8_t *)attr->data) ? true : false;
}

And similar for _put_bool() and _add_bool()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be:

static inline bool
blob_get_bool(const struct blob_attr *attr)
{
    return *((uint8_t *)attr->data) ? true : false;
}

And similar for _put_bool() and _add_bool()

@Alphix should be fixed in c640ad7

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure - the normal coercion to boolean happens elsewhere based on the uint 8 data, not on t/f, for existing implementations. But I've not looked this change as a whole.

In order to deprecate u8 functions we need to add proper boolean functions
first.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Deprecate u8 and u16 to 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: Álvaro Fernández Rojas <noltari@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants