linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zheng Yongjun <zhengyongjun3@huawei.com>
To: <jmaloy@redhat.com>, <ying.xue@windriver.com>,
	<davem@davemloft.net>, <kuba@kernel.org>,
	<netdev@vger.kernel.org>, <tipc-discussion@lists.sourceforge.net>,
	<linux-kernel@vger.kernel.org>
Cc: Zheng Yongjun <zhengyongjun3@huawei.com>
Subject: [PATCH net-next] net: tipc: Replace expression with offsetof()
Date: Tue, 22 Dec 2020 21:34:07 +0800	[thread overview]
Message-ID: <20201222133407.19861-1-zhengyongjun3@huawei.com> (raw)

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


             reply	other threads:[~2020-12-22 13:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-22 13:34 Zheng Yongjun [this message]
2020-12-23 18:43 ` [PATCH net-next] net: tipc: Replace expression with offsetof() Jakub Kicinski
2020-12-29 13:49 Zheng Yongjun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201222133407.19861-1-zhengyongjun3@huawei.com \
    --to=zhengyongjun3@huawei.com \
    --cc=davem@davemloft.net \
    --cc=jmaloy@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tipc-discussion@lists.sourceforge.net \
    --cc=ying.xue@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).