Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3783320ybi; Mon, 29 Jul 2019 12:32:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwg5jCzo2pyjxS6Zx7ckhPYE0VBr/ptdZF+dyXXxe2AZaySsLT9yT+ptmbn7ZFrLC5uQcz4 X-Received: by 2002:a63:2f44:: with SMTP id v65mr103578321pgv.185.1564428755106; Mon, 29 Jul 2019 12:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564428755; cv=none; d=google.com; s=arc-20160816; b=rC1BwKGftd+VfqD+ouLG1XHeVc5PxB5P5lHjl/n7ZR5lFZQ40UgmCA7cxHxOzvBST6 WzOD/C3iuLCYhhgYHXEkh7HHCW24ukpmsfMOK/uJ05UizPNnu2UwazDPplCk5qBNw98p zJmw/hUq4qP+B3wJ5AcFWsywM6Y3WyNESCEwDF2jlbhvX3JQWQfOyLvRLrIZHR/aaWxB XWKz1tSKlsYTo0zJe//f9tIe+xOXzWqjYJ49RCNNmyHTG+J02rFA4A+iRhf3DLV3dIbD XTKJ9r4nfMmQAxPZOwNY7P9fsVM1RcBSlCLxSZq8xjH90KRmQb3jqB3ZSBAdu/FhpjTo LfRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=kQoqTokV2t/xjbX6IsjsFLc/VupQwo6NdPPmnQdl/1M=; b=wugZ4aO3pxr7QIniE3MVnK4EXUCvUHlqtwSMB56oGxvHI6MMBYQ8F+22XRNj9FyVtF atZcPekL9oFT1Js5JpRi0SdAnMg+7/w5b6fHmk6kgb9UcJRbRM94oVqeRL9HbjfWE0om +uf7frKzyLMYwLDVaxKuNgZ3H0SvEJo5LoTRqmQpZmEGHNeDzW7BSG3uQmM+trlj9Dcl /uq9RGG0nVxIWqHpSNuNeLy6AKNECIQ9OF+Xd0LXudQM6vb+HD4xoDTtu9/O/ENTcAFM m6IJJleV/9ZoiEygVTlM0fahG9C0Nu7Tg2J5ByAyiW90FfNXkQhydPW8kDEG94Lw3av+ m3qA== 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 64si27523517plw.379.2019.07.29.12.32.20; Mon, 29 Jul 2019 12:32:35 -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 S1729326AbfG2TPO (ORCPT + 99 others); Mon, 29 Jul 2019 15:15:14 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:38572 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729309AbfG2TPO (ORCPT ); Mon, 29 Jul 2019 15:15:14 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 818E3802BB; Mon, 29 Jul 2019 21:15:00 +0200 (CEST) Date: Mon, 29 Jul 2019 21:15:12 +0200 From: Pavel Machek To: Chuhong Yuan Cc: "Rafael J . Wysocki" , Len Brown , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 07/12] power: Replace strncmp with str_has_prefix Message-ID: <20190729191511.GB2023@amd> References: <20190729151454.9606-1-hslester96@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="GRPZ8SYKNexpdSJ7" Content-Disposition: inline In-Reply-To: <20190729151454.9606-1-hslester96@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --GRPZ8SYKNexpdSJ7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon 2019-07-29 23:14:54, Chuhong Yuan wrote: > strncmp(str, const, len) is error-prone. > We had better use newly introduced > str_has_prefix() instead of it. >=20 > Signed-off-by: Chuhong Yuan > --- > kernel/power/hibernate.c | 8 ++++---- > kernel/power/main.c | 2 +- > 2 files changed, 5 insertions(+), 5 deletions(-) >=20 > diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c > index cd7434e6000d..49d4bfdb2b67 100644 > --- a/kernel/power/hibernate.c > +++ b/kernel/power/hibernate.c > @@ -1188,15 +1188,15 @@ static int __init resume_offset_setup(char *str) > =20 > static int __init hibernate_setup(char *str) > { > - if (!strncmp(str, "noresume", 8)) { > + if (str_has_prefix(str, "noresume")) { > noresume =3D 1; > - } else if (!strncmp(str, "nocompress", 10)) { > + } else if (str_has_prefix(str, "nocompress")) { > nocompress =3D 1; Ok, old code is bad, too... but this makes the error visible. We do not want "noresumenextmonday" to set noresume =3D 1, right? Pavel =09 --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --GRPZ8SYKNexpdSJ7 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl0/Rb8ACgkQMOfwapXb+vInuwCgm63IL4aJrE7dX7FYi1KtYfOC g7QAoIxTBaj1yYq/7ThkT594xjbmCZJI =+PIY -----END PGP SIGNATURE----- --GRPZ8SYKNexpdSJ7--