lkml.org 
[lkml]   [2019]   [Aug]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 4/8] printk: Replace strncmp with str_has_prefix
Hi Chuhong,

On Mon, Aug 5, 2019 at 2:24 PM Chuhong Yuan <hslester96@gmail.com> 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 code better.
>
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>

Thanks for your patch!

> --- a/kernel/printk/braille.c
> +++ b/kernel/printk/braille.c
> @@ -11,11 +11,13 @@
>
> int _braille_console_setup(char **str, char **brl_options)
> {
> - if (!strncmp(*str, "brl,", 4)) {
> + size_t len;
> +
> + if ((len = str_has_prefix(*str, "brl,"))) {

Please write this as

len = str_has_prefix(*str, "brl,");
if (len) {

(everywhere)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

\
 
 \ /
  Last update: 2019-08-06 10:09    [W:0.033 / U:0.628 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site