Re: [PATCH] net: core: datagram: tidy up copy functions a bit

From: Eric Dumazet
Date: Sun Oct 13 2019 - 15:30:56 EST




On 10/12/19 4:55 AM, Vito Caputo wrote:
> Eliminate some verbosity by using min() macro and consolidating some
> things, also fix inconsistent zero tests (! vs. == 0).
>
> Signed-off-by: Vito Caputo <vcaputo@xxxxxxxxxxx>
> ---
> net/core/datagram.c | 44 ++++++++++++++------------------------------
> 1 file changed, 14 insertions(+), 30 deletions(-)
>
> diff --git a/net/core/datagram.c b/net/core/datagram.c
> index 4cc8dc5db2b7..08d403f93952 100644
> --- a/net/core/datagram.c
> +++ b/net/core/datagram.c
> @@ -413,13 +413,11 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
> struct iov_iter *), void *data)
> {
> int start = skb_headlen(skb);
> - int i, copy = start - offset, start_off = offset, n;
> + int i, copy, start_off = offset, n;
> struct sk_buff *frag_iter;
>
> /* Copy header. */
> - if (copy > 0) {
> - if (copy > len)
> - copy = len;
> + if ((copy = min(start - offset, len)) > 0) {

No, we prefer not having this kind of construct anymore.

This refactoring looks unnecessary code churn, making our future backports not
clean cherry-picks.

Simply making sure this patch does not bring a regression is very time consuming.