Subject: Re: [Intel-wired-lan] [PATCH net-next v2 14/15] idpf: add ethtool callbacks

From: Simon Horman <[email-masked]>
Date: Sat, 22 Apr 2023 09:55:28 +0200

On Fri, Apr 21, 2023 at 10:26:25PM -0700, Tantilov, Emil S wrote:
> 
> 
> On 4/13/2023 12:11 PM, Tantilov, Emil S wrote:
> > 
> > 
> > On 4/11/2023 2:55 AM, Simon Horman wrote:
> > > On Mon, Apr 10, 2023 at 06:13:53PM -0700, Pavan Kumar Linga wrote:
> > > > From: Alan Brady <[email-masked]>
> > > 
> > > ...
> > > 
> > > > diff --git a/drivers/net/ethernet/intel/idpf/idpf_ethtool.c
> > > > b/drivers/net/ethernet/intel/idpf/idpf_ethtool.c
> > > 
> > > ...
> > > 
> > > > +/**
> > > > + * idpf_add_qstat_strings - Copy queue stat strings into ethtool buffer
> > > > + * @p: ethtool supplied buffer
> > > > + * @stats: stat definitions array
> > > > + * @type: stat type
> > > > + * @idx: stat idx
> > > > + *
> > > > + * Format and copy the strings described by the const static
> > > > stats value into
> > > > + * the buffer pointed at by p.
> > > > + *
> > > > + * The parameter @stats is evaluated twice, so parameters with
> > > > side effects
> > > > + * should be avoided. Additionally, stats must be an array such that
> > > > + * ARRAY_SIZE can be called on it.
> > > > + */
> > > > +#define idpf_add_qstat_strings(p, stats, type, idx) \
> > > > +    __idpf_add_qstat_strings(p, stats, ARRAY_SIZE(stats), type, idx)
> > > 
> > > Hi Pavan, Hi Alan,
> > > 
> > > FWIIW, I think __idpf_add_qstat_strings() could be a function.
> > > It would give some type checking. And avoid possible aliasing of inputs.
> > > Basically, I think functions should be used unless there is a reason
> > > not to.
> > > 
> > > ...
> > 
> > Good catch, we'll resolve it in v3.
> 
> The reason a macro is used in this case is that it allows
> __idpf_add_qstat_strings() to get the size of the arrays passed by the
> caller. Is there a way to do this if we convert the macro to a function?

Understood, in that case perhaps a macro is best after all.