The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Vito Caputo <vcaputo@pengaru.com>, Eric Dumazet <eric.dumazet@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: core: datagram: tidy up copy functions a bit
Date: Sun, 13 Oct 2019 13:17:18 -0700	[thread overview]
Message-ID: <6864f888-1b62-36c5-6ac5-d5db01c5fcfb@gmail.com> (raw)
In-Reply-To: <20191013200158.mhvwkdnsjk7ecuqu@shells.gnugeneration.com>



On 10/13/19 1:01 PM, Vito Caputo wrote:
> On Sun, Oct 13, 2019 at 12:30:41PM -0700, Eric Dumazet wrote:
>>
>>
>> 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@pengaru.com>
>>> ---
>>>  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.
> 
> Should I not bother submitting patches for such cleanups?
> 
> I submitted another, more trivial patch, is it also considered unnecessary churn:
> 
> ---
> 
> Author: Vito Caputo <vcaputo@pengaru.com>
> Date:   Sat Oct 12 17:10:41 2019 -0700
> 
>     net: core: skbuff: skb_checksum_setup() drop err
>     
>     Return directly from all switch cases, no point in storing in err.
>     
>     Signed-off-by: Vito Caputo <vcaputo@pengaru.com>
> 
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index f5f904f46893..c59b68a413b5 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -4888,23 +4888,14 @@ static int skb_checksum_setup_ipv6(struct sk_buff *skb, bool recalculate)
>   */
>  int skb_checksum_setup(struct sk_buff *skb, bool recalculate)
>  {
> -       int err;
> -
>         switch (skb->protocol) {
>         case htons(ETH_P_IP):
> -               err = skb_checksum_setup_ipv4(skb, recalculate);
> -               break;
> -
> +               return skb_checksum_setup_ipv4(skb, recalculate);
>         case htons(ETH_P_IPV6):
> -               err = skb_checksum_setup_ipv6(skb, recalculate);
> -               break;
> -
> +               return skb_checksum_setup_ipv6(skb, recalculate);
>         default:
> -               err = -EPROTO;
> -               break;
> +               return -EPROTO;
>         }
> -
> -       return err;
>  }
>  EXPORT_SYMBOL(skb_checksum_setup);
> 
> ---
> 
> Asking to calibrate my thresholds to yours, since I was planning to volunteer
> some time each evening to reading kernel code and submitting any obvious
> cleanups.
> 

This is not a cleanup.

You prefer seeing the code written the way you did, but that is really a matter of taste.

Think about backports of real bug fixes to stable kernels.

Having these re-writes of code make things less easy for us really.
So in general we tend to leave the existing code style.

I already replied to the other patch submission, please read

https://marc.info/?l=linux-netdev&m=157099669227635&w=2



  reply	other threads:[~2019-10-13 20:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-12 11:55 [PATCH] net: core: datagram: tidy up copy functions a bit Vito Caputo
2019-10-13 19:30 ` Eric Dumazet
2019-10-13 20:01   ` Vito Caputo
2019-10-13 20:17     ` Eric Dumazet [this message]
2019-10-13 22:41       ` Vito Caputo
2019-10-14  1:04         ` Eric Dumazet
2019-10-15 21:59 ` David Miller
2019-10-21  8:53 ` [net] 635f03c839: WARNING:at_net/core/datagram.c:#__skb_datagram_iter 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=6864f888-1b62-36c5-6ac5-d5db01c5fcfb@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vcaputo@pengaru.com \
    /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