[RFC PATCH v2 17/22] devlink: use min_t to calculate data_size

Jacob Keller
2020-02-14T23:23:03Z

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@kernel.org>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.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 e5bc0046f13f..60f4d231470e 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -4155,14 +4155,10 @@ 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.25.0.368.g28a2d05eebfb