[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221117220803.2773887-3-jacob.e.keller@intel.com>
Date: Thu, 17 Nov 2022 14:07:57 -0800
From: Jacob Keller <jacob.e.keller@...el.com>
To: netdev@...r.kernel.org
Cc: Jacob Keller <jacob.e.keller@...el.com>,
Jiri Pirko <jiri@...dia.com>, Jakub Kicinski <kuba@...nel.org>
Subject: [PATCH net-next 2/8] devlink: use min_t to calculate data_size
The calculation for the data_size in the devlink_nl_read_snapshot_fill
function uses an if statement that is better expressed using the min_t
macro.
Noticed-by: Jakub Kicinski <kuba@...nel.org>
Signed-off-by: Jacob Keller <jacob.e.keller@...el.com>
---
net/core/devlink.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 96afc7013959..932476956d7e 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -6410,14 +6410,10 @@ static int devlink_nl_region_read_snapshot_fill(struct sk_buff *skb,
*new_offset = start_offset;
while (curr_offset < end_offset) {
- u32 data_size;
+ u32 data_size = min_t(u32, end_offset - curr_offset,
+ DEVLINK_REGION_READ_CHUNK_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 = &snapshot->data[curr_offset];
err = devlink_nl_cmd_region_read_chunk_fill(skb, devlink,
data, data_size,
--
2.38.1.420.g319605f8f00e
Powered by blists - more mailing lists