[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d561b49935234451ac062f9f12c50e83@AcuMS.aculab.com>
Date: Thu, 24 Nov 2022 21:53:09 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Jacob Keller' <jacob.e.keller@...el.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC: Jiri Pirko <jiri@...dia.com>, Jakub Kicinski <kuba@...nel.org>
Subject: RE: [PATCH net-next v2 1/9] devlink: use min_t to calculate data_size
From: Jacob Keller
> Sent: 23 November 2022 20:38
>
> 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.
There ought to be a 'duck shoot' arranged for all uses of min_t().
I was testing a patch (I might submit next week) that relaxes the
checks in min() so that it doesn't error a lot of valid cases.
In particular a positive integer constant can always be cast to (int)
and the compare will DTRT.
I found things like min_t(u32, u32_length, u64_limit) where
you really don't want to mask the limit down.
There are also the min_t(u8, ...) and min_t(u16, ...).
...
> + data_size = min_t(u32, end_offset - curr_offset,
> + DEVLINK_REGION_READ_CHUNK_SIZE);
Here I think both xxx_offset are u32 - so the CHUNK_SIZE
constant probably needs a U suffix.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists