From: cgel.zte@gmail.com
To: jiri@nvidia.com
Cc: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Lv Ruyi <lv.ruyi@zte.com.cn>,
Zeal Robot <zealci@zte.com.cn>
Subject: [PATCH] devlink: use min() to make code cleaner
Date: Thu, 25 Nov 2021 07:14:14 +0000 [thread overview]
Message-ID: <20211125071414.53147-1-lv.ruyi@zte.com.cn> (raw)
From: Lv Ruyi <lv.ruyi@zte.com.cn>
Use the macro 'min()' defined in 'include/linux/minmax.h' to avoid
opencoding it.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
---
net/core/devlink.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/core/devlink.c b/net/core/devlink.c
index d144a62cbf73..6ffbbb02fb91 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -9,6 +9,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/minmax.h>
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/gfp.h>
@@ -5763,10 +5764,7 @@ static int devlink_nl_region_read_snapshot_fill(struct sk_buff *skb,
u32 data_size;
u8 *data;
- if (end_offset - curr_offset < DEVLINK_REGION_READ_CHUNK_SIZE)
- data_size = end_offset - curr_offset;
- else
- data_size = DEVLINK_REGION_READ_CHUNK_SIZE;
+ data_size = min(end_offset - curr_offset, DEVLINK_REGION_READ_CHUNK_SIZE);
data = &snapshot->data[curr_offset];
err = devlink_nl_cmd_region_read_chunk_fill(skb, devlink,
--
2.25.1
next reply other threads:[~2021-11-25 7:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-25 7:14 cgel.zte [this message]
2021-11-26 6:23 ` [PATCH] devlink: use min() to make code cleaner kernel test robot
2021-11-26 23:22 ` kernel test robot
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=20211125071414.53147-1-lv.ruyi@zte.com.cn \
--to=cgel.zte@gmail.com \
--cc=davem@davemloft.net \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lv.ruyi@zte.com.cn \
--cc=netdev@vger.kernel.org \
--cc=zealci@zte.com.cn \
/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).