diff mbox series

[v2,net-next,2/2] net: tipc: replace align() with ALIGN in msg.c

Message ID 20210609103251.534270-3-dong.menglong@zte.com.cn (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: tipc: fix FB_MTU eat two pages and do some code cleanup | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 48 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Menglong Dong June 9, 2021, 10:32 a.m. UTC
From: Menglong Dong <dong.menglong@zte.com.cn>

The function align() which is defined in msg.c is redundant, replace it
with ALIGN() and introduce a BUF_ALIGN().

Signed-off-by: Menglong Dong <dong.menglong@zte.com.cn>
---
 net/tipc/msg.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/net/tipc/msg.c b/net/tipc/msg.c
index a5c030ca7065..19a7d8eb8abb 100644
--- a/net/tipc/msg.c
+++ b/net/tipc/msg.c
@@ -49,6 +49,7 @@ 
 #define BUF_HEADROOM (LL_MAX_HEADER + 48)
 #define BUF_TAILROOM 0
 #endif
+#define BUF_ALIGN(x) ALIGN(x, 4)
 #define FB_MTU (PAGE_SIZE - \
 		SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) - \
 		SKB_DATA_ALIGN(BUF_HEADROOM + BUF_TAILROOM) \
@@ -56,11 +57,6 @@ 
 
 const int fb_mtu = FB_MTU;
 
-static unsigned int align(unsigned int i)
-{
-	return (i + 3) & ~3u;
-}
-
 /**
  * tipc_buf_acquire - creates a TIPC message buffer
  * @size: message size (including TIPC header)
@@ -489,10 +485,10 @@  static bool tipc_msg_bundle(struct sk_buff *bskb, struct tipc_msg *msg,
 	struct tipc_msg *bmsg = buf_msg(bskb);
 	u32 msz, bsz, offset, pad;
 
-	msz = msg_size(msg);
-	bsz = msg_size(bmsg);
-	offset = align(bsz);
-	pad = offset - bsz;
+	msz	= msg_size(msg);
+	bsz	= msg_size(bmsg);
+	offset	= BUF_ALIGN(bsz);
+	pad	= offset - bsz;
 
 	if (unlikely(skb_tailroom(bskb) < (pad + msz)))
 		return false;
@@ -548,7 +544,7 @@  bool tipc_msg_try_bundle(struct sk_buff *tskb, struct sk_buff **skb, u32 mss,
 
 	/* Make a new bundle of the two messages if possible */
 	tsz = msg_size(buf_msg(tskb));
-	if (unlikely(mss < align(INT_H_SIZE + tsz) + msg_size(msg)))
+	if (unlikely(mss < BUF_ALIGN(INT_H_SIZE + tsz) + msg_size(msg)))
 		return true;
 	if (unlikely(pskb_expand_head(tskb, INT_H_SIZE, mss - tsz - INT_H_SIZE,
 				      GFP_ATOMIC)))
@@ -607,7 +603,7 @@  bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos)
 	if (unlikely(!tipc_msg_validate(iskb)))
 		goto none;
 
-	*pos += align(imsz);
+	*pos += BUF_ALIGN(imsz);
 	return true;
 none:
 	kfree_skb(skb);