[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VciLg3KjeSAeEQyc1xa7o1cjoc5oEjYcGCK_MuSzmAWiw@mail.gmail.com>
Date: Wed, 14 Aug 2024 15:44:40 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Jani Nikula <jani.nikula@...el.com>
Cc: linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
intel-gfx@...ts.freedesktop.org, Kees Cook <keescook@...omium.org>,
Andy Shevchenko <andy@...nel.org>
Subject: Re: [PATCH v2 1/2] string: add mem_is_zero() helper to check if
memory area is all zeros
On Wed, Aug 14, 2024 at 1:00 PM Jani Nikula <jani.nikula@...el.com> wrote:
>
> Almost two thirds of the memchr_inv() usages check if the memory area is
> all zeros, with no interest in where in the buffer the first non-zero
> byte is located. Checking for !memchr_inv(s, 0, n) is also not very
> intuitive or discoverable. Add an explicit mem_is_zero() helper for this
> use case.
>
> Signed-off-by: Jani Nikula <jani.nikula@...el.com>
...
> void *memchr_inv(const void *s, int c, size_t n);
I would group them here, or move the above.
> char *strreplace(char *str, char old, char new);
>
> +/**
> + * mem_is_zero - Check if an area of memory is all 0's.
> + * @s: The memory area
> + * @n: The size of the area
> + *
> + * Return: True if the area of memory is all 0's.
> + */
> +static inline bool mem_is_zero(const void *s, size_t n)
> +{
> + return !memchr_inv(s, 0, n);
> +}
Reviewed-by: Andy Shevchenko <andy@...nel.org>
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists