From: Felix Fietkau Date: Wed, 23 Nov 2022 11:29:19 +0000 (+0100) Subject: blobmsg: add blobmsg_parse_attr function X-Git-Url: http://git.openwrt.org/feed/routing.git;lede-17.01?a=commitdiff_plain;h=b09b316aeaf6282bf2d2f7df9d2cc2cdf3977691;p=project%2Flibubox.git 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 --- 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) {