Re: [PATCH v4 6/8] sched: Replace strncmp with str_has_prefix

2019-08-29 Thread Peter Zijlstra
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

Re: [PATCH v4 6/8] sched: Replace strncmp with str_has_prefix

2019-08-09 Thread Chuhong Yuan
On Fri, Aug 9, 2019 at 7:31 PM Valentin Schneider wrote: > > On 09/08/2019 08:10, Chuhong Yuan wrote: > > strncmp(str, const, len) is error-prone because len > > is easy to have typo. > > The example is the hard-coded len has counting error > > or sizeof(const) forgets - 1. > > So we prefer using

Re: [PATCH v4 6/8] sched: Replace strncmp with str_has_prefix

2019-08-09 Thread Valentin Schneider
On 09/08/2019 08:10, Chuhong Yuan wrote: > strncmp(str, const, len) is error-prone because len > is easy to have typo. > The example is the hard-coded len has counting error > or sizeof(const) forgets - 1. > So we prefer using newly introduced str_has_prefix() > to substitute such strncmp to make

[PATCH v4 6/8] sched: Replace strncmp with str_has_prefix

2019-08-09 Thread Chuhong Yuan
strncmp(str, const, len) is error-prone because len is easy to have typo. The example is the hard-coded len has counting error or sizeof(const) forgets - 1. So we prefer using newly introduced str_has_prefix() to substitute such strncmp to make code better. Signed-off-by: Chuhong Yuan ---