DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Chaoyong He <chaoyong.he@corigine.com>, <dev@dpdk.org>,
	<oss-drivers@corigine.com>, "Long Wu" <long.wu@corigine.com>,
	Peng Zhang <peng.zhang@corigine.com>
Subject: Re: [PATCH] net/nfp: add support of UDP fragmentation offload
Date: Mon, 19 Feb 2024 10:26:08 +0000	[thread overview]
Message-ID: <ZdMswDk5MMmhnXKz@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F229@smartserver.smartshare.dk>

On Sun, Feb 18, 2024 at 11:05:35AM +0100, Morten Brørup wrote:
> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Saturday, 17 February 2024 19.11
> > 
> > On Sat, 17 Feb 2024 19:02:30 +0100
> > Morten Brørup <mb@smartsharesystems.com> wrote:
> > 
> > > Not formally... it follows the official DPDK Coding Style [1].
> > >
> > > [1]:
> > https://doc.dpdk.org/guides/contributing/coding_style.html#general
> > >
> > > > Should be:
> > > >
> > > > 	if ((ol_flags & RTE_MBUF_F_TX_TCP_SEG) == 0 &&
> > > > 	    (ol_flags & RTE_MBUF_F_TX_UDP_SEG) == 0)
> > > > 		goto clean_txd;
> > >
> > > This indentation style is mentioned as an alternative in the guide.
> > But the example in the guide also uses two tabs for a similar long
> > comparison.
> > >
> > > Personally, I also prefer the style suggested by Stephen, so we might
> > want to update the Coding Style. ;-)
> > 
> > 
> > The two tabs is an Intel thing, and I prefer the kernel, line up the
> > conditional style.
> 
> I prefer 4 space indentation, which is sufficient to notice the indentation. 8 spaces seems overkill to me, and quickly makes the lines too long.
> With the editor configured to show tab as 4 spaces, the kernel alignment style ends up with the same indentation for the condition and the code block:
> 
> if (a &&
>     b)
>     ctr++;
> 
> Whereas with the "tab as 4 spaces" editor configuration, the double indentation style clearly separates the continued condition from code block:
> 
> if (a &&
>         b)
>     ctr++;
> 

These two above are the main reasons I much prefer the double indent on
continuation, though I'd also add a third one: it means we don't have a mix
of tabs and spaces for indentation.

However, as stated already indent can be a matter of taste, and there will
be some disagreement about it. The existing coding standards document what
was done in the code base when they were written, and I don't think we
should look to change them. It's a bit annoying having 2 standards for
continuation rather than 1, but it's not exactly a free-for-all, and it's
not something that applies to every line, only to a small subset.

> On the other hand, complex conditions are easier readable when aligning logically instead of by a fixed number of tabs, e.g.:
> 
> if (a |
>     (b &
>      (c ^ d)) |
>     (e ^ f) |
>     g)
>     ctr++;
> 

Apart from the alignment of the increment at the end, yes, I admit it is a
little more readable. However, I also think that it's still pretty complex
even with the helpers!

> Placing the operators at the beginning also makes the code more readable:
> 
> if (a
>     | (b
>        & (c ^ d))
>     | (e ^ f)
>     | g)
>     ctr++;
> 

+1 to this. I think having operators at the beginning of lines is good. It
also makes it visually clearer that the indent is for line continuation.

> I guess that coding styles are mostly a matter of taste.
> 
> I wonder if any research into coding styles has reached any conclusions or recommendations, beyond mixing coding styles is bad for readability.
> 
> > We really should have a style that can be describe by clang format.
> > Other projects like VPP have a target that reformats the code and uses
> > one of the clang format templates.
> 
> Automated code formatting seems like a good idea.
> 

Yep. The trouble is that, if you don't do this from the start, the deltas
will be massive, and confusing in our git history.

/Bruce

  reply	other threads:[~2024-02-19 10:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-17  1:54 Chaoyong He
2024-02-17 16:47 ` Stephen Hemminger
2024-02-17 18:02   ` Morten Brørup
2024-02-17 18:11     ` Stephen Hemminger
2024-02-18 10:05       ` Morten Brørup
2024-02-19 10:26         ` Bruce Richardson [this message]
2024-02-19 10:28           ` Ferruh Yigit
2024-02-19 13:30   ` Ferruh Yigit
2024-02-19 13:41 ` Ferruh Yigit
2024-02-20  7:54   ` Chaoyong He
2024-02-19 14:20 ` Ferruh Yigit

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=ZdMswDk5MMmhnXKz@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=mb@smartsharesystems.com \
    --cc=oss-drivers@corigine.com \
    --cc=peng.zhang@corigine.com \
    --cc=stephen@networkplumber.org \
    /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;
as well as URLs for NNTP newsgroup(s).