netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Seiderer <ps.report@gmx.net>
To: Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH net-next v4 09/17] net: pktgen: align some variable declarations to the most common pattern
Date: Tue, 11 Feb 2025 10:29:59 +0100	[thread overview]
Message-ID: <20250211102959.4aeeb806@gmx.net> (raw)
In-Reply-To: <20250206132538.GU554665@kernel.org>

Hello Simon,

On Thu, 6 Feb 2025 13:25:38 +0000, Simon Horman <horms@kernel.org> wrote:

> On Wed, Feb 05, 2025 at 02:11:45PM +0100, Peter Seiderer wrote:
> > Align some variable declarations (in get_imix_entries and get_labels) to
> > the most common pattern (int instead of ssize_t/long) and adjust function
> > return value accordingly.
> >
> > Signed-off-by: Peter Seiderer <ps.report@gmx.net>
>
> Hi Peter,
>
> These comments are is true in general of this patchset, but particularly so
> in the case of this patch:
>
> * I think a more succinct subject would be nice.
> * I think the patch description should provide some reason
>   _why_ the change is being made.

Yep, will improve...

>
> Also, specifically relating to this patch, I wonder if it's scope ought to
> be extended. For example, the two callers of num_arg(), get_imix_entries() and
> pktgen_if_write() assign the return value of num_arg() to len, which is now
> an int in both functions. But num_args() returns a long.

Aim was to get rid of the int/long mixture in the code (which works flawless
because no one writes to proc with more than a few bytes AND count is limited
to INT_MAX - PAGE_SIZE in vfs_write (see [1], [2])...

I believe the clean way is to use

  size_t i, max;
  ssize_t len;

consequently through out the code and adjust the function signatures
accordingly...., will re-spin...

>
> > ---
> > Changes v3 -> v4
> >   - new patch (factored out of patch 'net: pktgen: fix access outside of user
> >     given buffer in pktgen_if_write()')
> > ---
> >  net/core/pktgen.c | 14 ++++++--------
> >  1 file changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> > index 4f201a2db2dc..279910367ad4 100644
> > --- a/net/core/pktgen.c
> > +++ b/net/core/pktgen.c
> > @@ -850,12 +850,11 @@ static int strn_len(const char __user * user_buffer, unsigned int maxlen)
> >   * where each entry consists of size and weight delimited by commas.
> >   * "size1,weight_1 size2,weight_2 ... size_n,weight_n" for example.
> >   */
> > -static ssize_t get_imix_entries(const char __user *buffer,
> > -				struct pktgen_dev *pkt_dev)
> > +static int get_imix_entries(const char __user *buffer,
> > +			    struct pktgen_dev *pkt_dev)
> >  {
> > -	int i = 0;
> > -	long len;
> >  	char c;
> > +	int i = 0, len;
>
> Given it can be achieved with exactly the same lines changed, just in a
> different order, please arrange the local variable declarations in reverse
> xmas tree order - longest line to shortest.
>
> Likewise for the other hunk of this patch.  And I believe there are also
> other cases in this patchset where this comment applied.
>
> The following tool can be useful:
> https://github.com/ecree-solarflare/xmastree

O.k. will take a look at it...

Thanks for review!

Regards,
Peter


[1] https://elixir.bootlin.com/linux/v6.13.1/source/fs/read_write.c#L673
[2] https://elixir.bootlin.com/linux/v6.13.1/source/include/linux/fs.h#L2704

  reply	other threads:[~2025-02-11  9:30 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 13:11 [PATCH net-next v4 00/17] Some pktgen fixes/improvments Peter Seiderer
2025-02-05 13:11 ` [PATCH net-next v4 01/17] net: pktgen: replace ENOTSUPP with EOPNOTSUPP Peter Seiderer
2025-02-05 13:11 ` [PATCH net-next v4 02/17] net: pktgen: enable 'param=value' parsing Peter Seiderer
2025-02-05 13:11 ` [PATCH net-next v4 03/17] net: pktgen: fix hex32_arg parsing for short reads Peter Seiderer
2025-02-05 13:11 ` [PATCH net-next v4 04/17] net: pktgen: fix 'rate 0' error handling (return -EINVAL) Peter Seiderer
2025-02-05 13:11 ` [PATCH net-next v4 05/17] net: pktgen: fix 'ratep " Peter Seiderer
2025-02-05 13:11 ` [PATCH net-next v4 06/17] net: pktgen: fix ctrl interface command parsing Peter Seiderer
2025-02-05 13:11 ` [PATCH net-next v4 07/17] net: pktgen: fix access outside of user given buffer in pktgen_thread_write() Peter Seiderer
2025-02-05 13:11 ` [PATCH net-next v4 08/17] net: pktgen: use defines for the various dec/hex number parsing digits lengths Peter Seiderer
2025-02-06 13:14   ` Simon Horman
2025-02-05 13:11 ` [PATCH net-next v4 09/17] net: pktgen: align some variable declarations to the most common pattern Peter Seiderer
2025-02-06 13:25   ` Simon Horman
2025-02-11  9:29     ` Peter Seiderer [this message]
2025-02-11 10:15       ` Simon Horman
2025-02-05 13:11 ` [PATCH net-next v4 10/17] net: pktgen: remove extra tmp variable (re-use len instead) Peter Seiderer
2025-02-06 13:12   ` Simon Horman
2025-02-05 13:11 ` [PATCH net-next v4 11/17] net: pktgen: remove some superfluous variable initializing Peter Seiderer
2025-02-06 13:11   ` Simon Horman
2025-02-05 13:11 ` [PATCH net-next v4 12/17] net: pktgen: fix mpls maximum labels list parsing Peter Seiderer
2025-02-06 13:04   ` Simon Horman
2025-02-05 13:11 ` [PATCH net-next v4 13/17] net: pktgen: fix access outside of user given buffer in pktgen_if_write() Peter Seiderer
2025-02-06 16:01   ` Simon Horman
2025-02-05 13:11 ` [PATCH net-next v4 14/17] net: pktgen: hex32_arg/num_arg error out in case no characters are available Peter Seiderer
2025-02-06 16:04   ` Simon Horman
2025-02-05 13:11 ` [PATCH net-next v4 15/17] net: pktgen: num_arg error out in case no valid character is parsed Peter Seiderer
2025-02-05 13:11 ` [PATCH net-next v4 16/17] net: pktgen: fix mpls reset parsing Peter Seiderer
2025-02-05 13:11 ` [PATCH net-next v4 17/17] selftest: net: add proc_net_pktgen Peter Seiderer
2025-02-06 13:51 ` [PATCH net-next v4 00/17] Some pktgen fixes/improvments Simon Horman
2025-02-11  9:36   ` Peter Seiderer

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=20250211102959.4aeeb806@gmx.net \
    --to=ps.report@gmx.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.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).