From b09b316aeaf6282bf2d2f7df9d2cc2cdf3977691 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 23 Nov 2022 12:29:19 +0100 Subject: [PATCH] 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 --- blobmsg.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/blobmsg.h b/blobmsg.h index 5feaffe..a465ad5 100644 --- a/blobmsg.h +++ b/blobmsg.h @@ -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) { -- 2.30.2