From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Chuhong Yuan <hslester96@gmail.com>
Cc: Petr Mladek <pmladek@suse.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Joe Perches <joe@perches.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 4/8] printk: Replace strncmp with str_has_prefix
Date: Tue, 6 Aug 2019 10:07:58 +0200 [thread overview]
Message-ID: <CAMuHMdVh=rX+MuhvqwTthcbq95bTPCz1dCFV4BixR2UA4J5+bg@mail.gmail.com> (raw)
In-Reply-To: <20190805122254.13041-1-hslester96@gmail.com>
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
prev parent reply other threads:[~2019-08-06 8:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-05 12:22 [PATCH v3 4/8] printk: Replace strncmp with str_has_prefix Chuhong Yuan
2019-08-06 8:07 ` Geert Uytterhoeven [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMuHMdVh=rX+MuhvqwTthcbq95bTPCz1dCFV4BixR2UA4J5+bg@mail.gmail.com' \
--to=geert@linux-m68k.org \
--cc=hslester96@gmail.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).