blobmsg: add a helper function to reset the name of a blobmsg attribute

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
Felix Fietkau 2014-07-21 01:24:01 +02:00
parent bd388d2b6c
commit f3977836af

View file

@ -51,6 +51,12 @@ static inline int blobmsg_hdrlen(unsigned int namelen)
return BLOBMSG_PADDING(sizeof(struct blobmsg_hdr) + namelen + 1); return BLOBMSG_PADDING(sizeof(struct blobmsg_hdr) + namelen + 1);
} }
static inline void blobmsg_clear_name(struct blob_attr *attr)
{
struct blobmsg_hdr *hdr = (struct blobmsg_hdr *) blob_data(attr);
hdr->name[0] = 0;
}
static inline const char *blobmsg_name(const struct blob_attr *attr) static inline const char *blobmsg_name(const struct blob_attr *attr)
{ {
struct blobmsg_hdr *hdr = (struct blobmsg_hdr *) blob_data(attr); struct blobmsg_hdr *hdr = (struct blobmsg_hdr *) blob_data(attr);