Re: [v2 01/10] utils_macro: introduce find_closest_unsorted()

From: Andy Shevchenko
Date: Thu Oct 28 2021 - 06:26:47 EST


On Thu, Oct 28, 2021 at 1:18 PM Andrea Merello <andrea.merello@xxxxxxxxx> wrote:
>
> This is similar to find_closest() and find_closest_descending(), but, it
> doesn't make any assumption about the array being ordered.

Macros in general are not so welcoming.
Why do you do it as a macro?

...

> +#include <linux/math.h>

Wondering if the current header misses other inclusions it's a direct user of.

...

> +/**
> + * find_closest_unsorted - locate the closest element in a unsorted array

an

> + * @x: The reference value.
> + * @a: The array in which to look for the closest element.
> + * @as: Size of 'a'.
> + *
> + * Similar to find_closest() but 'a' has no requirement to being sorted
> + */

--
With Best Regards,
Andy Shevchenko