[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VcWXCeQo4n67cfq0VQaO-+YW-=iqKx+r4NtFfYnJBTBFA@mail.gmail.com>
Date: Mon, 27 May 2024 16:27:05 +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 1/2] string: add mem_is_zero() helper to check if memory
area is all zeros
On Mon, May 27, 2024 at 12:43 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.
..
> +static inline bool mem_is_zero(const void *s, size_t n)
> +{
> + return !memchr_inv(s, 0, n);
> +}
There are potential users for the 0xff check as well. Hence the
following question:
Are we going to have a new function per byte in question, or do we
come up with a common denominator, like mem_is_all_of(mem, byte)?
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists