On Fri, Jan 20, 2023 at 05:11:27PM +0200, Andy Shevchenko wrote: > On Fri, Jan 20, 2023 at 11:58:52AM +0000, Sakari Ailus wrote: > > On Thu, Jan 19, 2023 at 06:09:25PM +0200, Andy Shevchenko wrote: > > > On Thu, Jan 19, 2023 at 03:51:33PM +0000, Sakari Ailus wrote: > > > > On Tue, Jan 17, 2023 at 05:29:54PM +0200, Andy Shevchenko wrote: > > > > > On Tue, Jan 17, 2023 at 02:22:43PM +0200, Sakari Ailus wrote: > > ... > > > > > > > + if (memcmp(elements[0].string.pointer, MIPI_IMG_PREFIX, > > > > > > + sizeof(MIPI_IMG_PREFIX) - 1)) > > > > > > > > > > str_has_prefix() > > > > > > > > str_has_prefix() calls strlen() on prefix on every call. sizeof() will > > > > generate much less code --- it's just a number. > > > > > > Have you tried that? Because the strlen() over const string literals will be > > > optimized away on compilation time. > > > > Actually not. There seem to be an implementation of strlen() in > > include/linux/fortify-string.h that would seem to be capable of doing that. > > However its use is conditional to kernel configuration. > > Ah, you missed probably the ability of the complier to find constant literals > and replace the strlen() with plain number. It seems GCC does this if -foptimize-strlen (included in -O2) is given. Fair enough, I'll replace it with str_has_prefix() for v2. -- Sakari Ailus