Re: [PATCH 2/2] lib/string.c: Optimize memchr()
From: Andy Shevchenko
Date: Mon Jul 11 2022 - 11:03:53 EST
On Mon, Jul 11, 2022 at 5:00 PM Andrey Semashev
<andrey.semashev@xxxxxxxxx> wrote:
> On 7/11/22 17:52, Yu-Jen Chang wrote:
...
> I think you're missing the point. Loads at unaligned addresses may not
> be allowed by hardware using conventional load instructions or may be
> inefficient. Given that this memchr implementation is used as a fallback
> when no hardware-specific version is available, you should be
> conservative wrt. hardware capabilities and behavior. You should
> probably have a pre-alignment loop.
Exactly!
The initial code is broken, NAK.
P.S. At least you may look into strscpy() implementation to get a clue.
--
With Best Regards,
Andy Shevchenko