Re: [PATCH v3 06/12] minmax: Introduce {min,max}_array()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 13 Jun 2023 20:08:08 +0300
Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:

> On Tue, Jun 13, 2023 at 11:00 AM Herve Codina <herve.codina@xxxxxxxxxxx> wrote:
> > On Mon, 12 Jun 2023 17:10:40 +0300
> > Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:  
> > > On Mon, Jun 12, 2023 at 3:30 PM Herve Codina <herve.codina@xxxxxxxxxxx> wrote:  
> > > >
> > > > Introduce min_array() (resp max_array()) in order to get the
> > > > minimal (resp maximum) of values present in an array.  
> > >
> > > Some comments below, after addressing them,
> > > Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>  
> 
> ...
> 
> > > > +       typeof(array) __array = (array);                        \  
> > >
> > > We have __must_be_array()  
> >
> > Using __must_be_array() will lead to some failure.
> > Indeed, we can have:
> >   --- 8< ---
> >   int *buff
> >   ...
> >   min = min_array(buff, nb_item);
> >   --- 8< ---
> >
> > In this case, __must_be_array() will report that buff is not an array.  
> 
> Oh, I missed that.
> 
> > To avoid any confusion, what do you think if I renamed {min,max}_array()
> > to {min,max}_buffer() and replace __array by __buff and use *(__buff + xxx)
> > instead of array[xxx] in the macro.  
> 
> But functionally it's still against an array.
> 
> I would stick with "array" in the name, but add a comment why
> __must_be_array() is not used. If we need a stricter variant, we may
> add a new wrapper with that check. That said, I think we can use
> __array[0] and similar indexed accesses.
> 

Right, I will provide an updated version on the next iteration.

Thanks for your feedback.
Hervé



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux