[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMuHMdVh=rX+MuhvqwTthcbq95bTPCz1dCFV4BixR2UA4J5+bg@mail.gmail.com>
Date: Tue, 6 Aug 2019 10:07:58 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Chuhong Yuan <hslester96@...il.com>
Cc: Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Joe Perches <joe@...ches.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [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@...il.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@...il.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@...ux-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
Powered by blists - more mailing lists