Re: [PATCH] lib/list_sort: fix function type mismatches
From: Andy Shevchenko
Date: Sat Jan 11 2020 - 05:55:28 EST
On Sat, Jan 11, 2020 at 12:35 PM Andy Shevchenko
<andy.shevchenko@xxxxxxxxx> wrote:
> On Sat, Jan 11, 2020 at 10:31 AM George Spelvin <lkml@xxxxxxx> wrote:
> >
> > > typedef int __attribute__((nonnull(2,3))) (*cmp_func)(void *,
> > > - struct list_head const *, struct list_head const *);
> > > + struct list_head *, struct list_head *);
> >
> > I'd prefer to leave the const there for documentation.
>
> Not only. It's useful to show that we are not going to change those parameters.
>
> > Does anyone object to fixing it in the other direction by *adding*
> > const to all the call sites?
>
> Agree.
> Actually we have cmp_r_funct_t which might be used here (I didn't
> check for the possibility, though).
For the record, I have just checked users of list_sort() in regard to
constify of priv parameter and only ACPI HMAT is using it as not
const. UBIFS and XFS do not change the data (if I didn't miss
anything).
But the amount of changes there perhaps not worth of doing. So, maybe
new type like
cmp_w_func_t where priv is not const would be good enough for merge().
--
With Best Regards,
Andy Shevchenko