diff mbox series

[OpenWrt-Devel,libubox,20/20] blobmsg: reuse blobmsg_namelen in blobmsg_data

Message ID 20191219215836.21773-21-ynezz@true.cz
State Accepted
Delegated to: Petr Štetiar
Headers show
Series tests, fuzzing, fixes and improvements | expand

Commit Message

Petr Štetiar Dec. 19, 2019, 9:58 p.m. UTC
Move blobmsg_namelen into header file so it's possible to reuse it in
blobmsg_data.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 blobmsg.c | 6 ------
 blobmsg.h | 7 ++++++-
 2 files changed, 6 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/blobmsg.c b/blobmsg.c
index 7cd0934600de..48dba8156d58 100644
--- a/blobmsg.c
+++ b/blobmsg.c
@@ -25,12 +25,6 @@  static const int blob_type[__BLOBMSG_TYPE_LAST] = {
 	[BLOBMSG_TYPE_UNSPEC] = BLOB_ATTR_BINARY,
 };
 
-static uint16_t
-blobmsg_namelen(const struct blobmsg_hdr *hdr)
-{
-	return be16_to_cpu(hdr->namelen);
-}
-
 bool blobmsg_check_attr(const struct blob_attr *attr, bool name)
 {
 	return blobmsg_check_attr_len(attr, name, blob_raw_len(attr));
diff --git a/blobmsg.h b/blobmsg.h
index af88c1feb86f..be3c7ee2cbfd 100644
--- a/blobmsg.h
+++ b/blobmsg.h
@@ -69,6 +69,11 @@  static inline int blobmsg_type(const struct blob_attr *attr)
 	return blob_id(attr);
 }
 
+static uint16_t blobmsg_namelen(const struct blobmsg_hdr *hdr)
+{
+	return be16_to_cpu(hdr->namelen);
+}
+
 static inline void *blobmsg_data(const struct blob_attr *attr)
 {
 	struct blobmsg_hdr *hdr;
@@ -81,7 +86,7 @@  static inline void *blobmsg_data(const struct blob_attr *attr)
 	data = (char *) blob_data(attr);
 
 	if (blob_is_extended(attr))
-		data += blobmsg_hdrlen(be16_to_cpu(hdr->namelen));
+		data += blobmsg_hdrlen(blobmsg_namelen(hdr));
 
 	return data;
 }