Re: [PATCH v4 6/8] sched: Replace strncmp with str_has_prefix
From: Peter Zijlstra
Date: Thu Aug 29 2019 - 08:34:57 EST
On Fri, Aug 09, 2019 at 03:10:51PM +0800, Chuhong Yuan wrote:
> strncmp(str, const, len) is error-prone because len
> is easy to have typo.
I'm thinking that is exactly the easy case for compilers/semantic
checkers to verify. Now granted, GCC doesn't seem to do that by itself,
but still.
I'd buy your argument if the prefix is variable, because in that case
you can do prefix matching cheaper than strlen+strncmp, but as is, not
really.