Messages in this thread | | | From | Geert Uytterhoeven <> | Date | Tue, 6 Aug 2019 10:07:58 +0200 | 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@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
| |