linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: tipc: Replace expression with offsetof()
@ 2020-12-22 13:34 Zheng Yongjun
  2020-12-23 18:43 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Zheng Yongjun @ 2020-12-22 13:34 UTC (permalink / raw)
  To: jmaloy, ying.xue, davem, kuba, netdev, tipc-discussion, linux-kernel
  Cc: Zheng Yongjun

Use the existing offsetof() macro instead of duplicating code.

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 net/tipc/monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c
index 6dce2abf436e..48fac3b17e40 100644
--- a/net/tipc/monitor.c
+++ b/net/tipc/monitor.c
@@ -108,7 +108,7 @@ const int tipc_max_domain_size = sizeof(struct tipc_mon_domain);
  */
 static int dom_rec_len(struct tipc_mon_domain *dom, u16 mcnt)
 {
-	return ((void *)&dom->members - (void *)dom) + (mcnt * sizeof(u32));
+	return (offsetof(struct tipc_mon_domain, members)) + (mcnt * sizeof(u32));
 }
 
 /* dom_size() : calculate size of own domain based on number of peers
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH net-next] net: tipc: Replace expression with offsetof()
@ 2020-12-29 13:49 Zheng Yongjun
  0 siblings, 0 replies; 3+ messages in thread
From: Zheng Yongjun @ 2020-12-29 13:49 UTC (permalink / raw)
  To: jmaloy, ying.xue, davem, kuba, netdev, tipc-discussion, linux-kernel
  Cc: Zheng Yongjun

Use the existing offsetof() macro instead of duplicating code.

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 net/tipc/monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c
index 6dce2abf436e..48fac3b17e40 100644
--- a/net/tipc/monitor.c
+++ b/net/tipc/monitor.c
@@ -108,7 +108,7 @@ const int tipc_max_domain_size = sizeof(struct tipc_mon_domain);
  */
 static int dom_rec_len(struct tipc_mon_domain *dom, u16 mcnt)
 {
-	return ((void *)&dom->members - (void *)dom) + (mcnt * sizeof(u32));
+	return (offsetof(struct tipc_mon_domain, members)) + (mcnt * sizeof(u32));
 }
 
 /* dom_size() : calculate size of own domain based on number of peers
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-29 13:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-22 13:34 [PATCH net-next] net: tipc: Replace expression with offsetof() Zheng Yongjun
2020-12-23 18:43 ` Jakub Kicinski
2020-12-29 13:49 Zheng Yongjun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).