Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3778002ybh; Tue, 6 Aug 2019 01:09:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9re7Zgx3CKvs+Rs5pZfDnFOjc1bQSymJB9nxUPpPN4EmKQrjPujeLIWdsAFase7F2D1AI X-Received: by 2002:a62:e71a:: with SMTP id s26mr2283494pfh.89.1565078940125; Tue, 06 Aug 2019 01:09:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565078940; cv=none; d=google.com; s=arc-20160816; b=iItG2vQcoyaXaY0XfY0QhHwT5Q36TGx/5/2Nk6sFOxMf8IRMzEwXv5u+SDGEpfH/9G nd9peelGtm2HuFIGVZf30A2iMuT8EjNJSDOTSg9CcLcdo4cUOvLOElcWCxxxN3Tmf2+P zA20Obkd7rivI+SdlSzfUQ5o97Xd3h1/WV0bOl0l9rHTCwUwB5rJpabEeR0bDdY/DpMY ZHzSSYDXjVYHghA495AD8MmBBk5cERL617oS3ejUYLg/PTQ6CZ+nLjQaTJyrJe7EaKnL SVn5jl2h6bRdw01L92uKJ2ObXktfHF4Y3X8sxnf9aObl98qP4DMniH0B8KrQOsDLNciw Umsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=v0pUxoN8ic5Jg7+9svSK19LHhymmTCOYPQ9hSacaUJA=; b=edC17LcYWvO9zpmY1CikcAsrVNmLHn+OUrUzyDqWRdz8i5E+Jyptg2E2Qie+Ul2SlZ AMGEfrBzH2TCxqXOsHt5oDdlWZwKBnqXZbtDbXJipASZb6ut4P4ZS7fZ9TdSTXmIhW5c cHo1wqhub2Pif2mUwWNgvBVtEUq2UxepIXPTHhyiQfAeJVEHR191FSAWri+UtBjbr3YK oFVSOdvn7vwX1Xy/Z/cjepouFr9w4EjOO0jnSU87ieO0aU88yknd1QDKfkV+yYeVyjMA gfNwGBKYAoSCJCVLBnWrstdAZ6wu++w7wXN4sUZbtirNrbZUquXSBVQvYysgI7cKeWt9 RaXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q187si45621108pfb.51.2019.08.06.01.08.44; Tue, 06 Aug 2019 01:09:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732079AbfHFIIK (ORCPT + 99 others); Tue, 6 Aug 2019 04:08:10 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:36680 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728991AbfHFIIK (ORCPT ); Tue, 6 Aug 2019 04:08:10 -0400 Received: by mail-ot1-f66.google.com with SMTP id r6so90339699oti.3 for ; Tue, 06 Aug 2019 01:08:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=v0pUxoN8ic5Jg7+9svSK19LHhymmTCOYPQ9hSacaUJA=; b=qe7Q3xwN3HGtpx9UnDIhDguhXMcHAFqXWQ2n5h8tjWYzxviwVlc3LFwbfXAjDT4ULy v7eR7GkoKyxEtTbP+1MyHrhgJzeiL13dPLupxGpZQJiPfoXBsPa7m0gLiI0gtXauV+JA VuUaUgWQQpI/qS+h9r80Exz3Z6do0njbu0mE9qkbML6Pzy+Xbs+8XFx9+grnBmZayB6N iK04ex9EfvJpqApEwnubOsdcIP/smuF03uMa0Fk01V8TQ87X4CyYMtFaOTym42o+UDo8 MLXAMUQKN81o+MAuWN2/eG9kVFS+QCFuDLVIa9UV2mej1zlhxlUGZhyxwxIBI5EqwYCS 2aFg== X-Gm-Message-State: APjAAAVNjkKFxyTpJhkgXa0IF5TSKng8rcn5nETyUr9MJjNflwHuyhHv 76MUXO/snmSQTBTGryvUZm5Rr49dc509P3GJVOs= X-Received: by 2002:a05:6830:210f:: with SMTP id i15mr2097796otc.250.1565078889511; Tue, 06 Aug 2019 01:08:09 -0700 (PDT) MIME-Version: 1.0 References: <20190805122254.13041-1-hslester96@gmail.com> In-Reply-To: <20190805122254.13041-1-hslester96@gmail.com> From: Geert Uytterhoeven Date: Tue, 6 Aug 2019 10:07:58 +0200 Message-ID: Subject: Re: [PATCH v3 4/8] printk: Replace strncmp with str_has_prefix To: Chuhong Yuan Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Joe Perches , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chuhong, On Mon, Aug 5, 2019 at 2:24 PM 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 code better. > > Signed-off-by: Chuhong Yuan 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