blobmsg: add blobmsg_parse_attr function

This allows turning the common pattern of:
  blobmsg_parse(policy, ARRAY_SIZE(policy), tb, blobmsg_data(data), blobmsg_len(data));

into:
  blobmsg_parse_attr(policy, ARRAY_SIZE(policy), tb, data);

Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
Felix Fietkau 2022-11-23 12:29:19 +01:00
parent ea56013409
commit b09b316aea

View file

@ -178,6 +178,13 @@ int blobmsg_parse_array(const struct blobmsg_policy *policy, int policy_len,
int blobmsg_add_field(struct blob_buf *buf, int type, const char *name,
const void *data, unsigned int len);
static inline int
blobmsg_parse_attr(const struct blobmsg_policy *policy, int policy_len,
struct blob_attr **tb, struct blob_attr *data)
{
return blobmsg_parse(policy, policy_len, tb, blobmsg_data(data), blobmsg_len(data));
}
static inline int
blobmsg_add_double(struct blob_buf *buf, const char *name, double val)
{