Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7023907ybi; Thu, 1 Aug 2019 02:03:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKKopmCdapq9AoMKf35xoCzpIYqpfxbM6cjLticBUCwTpMV50bCWHOKGAQkyXyaOzCDY6+ X-Received: by 2002:a62:b60e:: with SMTP id j14mr52685386pff.54.1564650239799; Thu, 01 Aug 2019 02:03:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564650239; cv=none; d=google.com; s=arc-20160816; b=qh2W54I1+cb7s1doht50HOq6SBROs1NrYRPGgbakd7rHXfqJywKT4l6VrWb9J1hNaU eunvY8v1tTTtEOH2eWnkpbm6KQxRYXn/7EKi+hI7r+CHg+LZuA4GN6rxi7mbovz+C2fc Z0wZp4r7D8z5mWIgra+cmw0R3uKfgBYEzCbhEagaFWG+F628xMulG75kMCc8DapYWqZW 6j+w8sxYbtkAdGGoCE+fcfgnI7v9d8O/+lQIz5cZNqTX3i0LkplNxY3OSJz1wos6XSw1 qeoVcDctPs8Aze0yTmwzsqG5bbqQy8wtQm9+V8nYnjPEogYhvTmYz1dwvWaFpIExFWPa RUrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=/A98ENoFGQr2SCQn9ABBf4M5URnbGIlXVcItSyIlQIY=; b=oBD8eisaUGF7g9aCLV24gs5dLialsP6DtOr9A2eoxjrN0nMfGFM1Iu8b6uO57bb0Ne hTWGtRrhdAQWzVDLzSu44rCrKaU3YxfWXI1fsKpromJ+VTiMcWP/maOYJFrOxN05Pfi8 SIbe1nOnXUiqe0Moi++WpbHYB6DeG0/BQNLE47ysPH9fhel245yvVBWEJt6cimaTxo/v S8EV33mkYNWcz2DGtfe3/dKD4I46Ti3e8wfz++o9LvdHgo661O8XoSiQZ6bK7U6aeQV0 wOlPv8xuwwlm/JDAnhY/wsQ2vR0OSCBDtAM3NgtnodpqzBdW0Puwbqs+WTmslqilUOZJ Li7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Wpfuc/Jm"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r200si31966461pgr.518.2019.08.01.02.03.39; Thu, 01 Aug 2019 02:03:59 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Wpfuc/Jm"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730910AbfHAIIA (ORCPT + 99 others); Thu, 1 Aug 2019 04:08:00 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:35492 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729572AbfHAIH7 (ORCPT ); Thu, 1 Aug 2019 04:07:59 -0400 Received: by mail-ed1-f66.google.com with SMTP id w20so68257417edd.2; Thu, 01 Aug 2019 01:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=/A98ENoFGQr2SCQn9ABBf4M5URnbGIlXVcItSyIlQIY=; b=Wpfuc/Jm6RyYET0+1F4x08xRLhNOqe5AZMmhCVijzNJP0ZYLJnTwSDSFDJw4yTm9ts GEQJ0hM6YnpfnbAcWoA1PXGG/NunmgXCF89xCSgAx4qkFc7lBDGuN6lm3Nz3JTSNMpFw pAlgYEVRRXnQmVqy41rIOnkkXV1TE9BmCOMSiQpQO3QsPYXzCCgzPucE8gKyMfAGlgWP hiN1704KehFy0lXo+asJa+it+YSV4ckYq0QfCU8uKWBKFdcIiCPH6ivx54ru8hjqxAfm X/oIQPD6gH/w4WFdbmMNAWbpaL478XNI6RiZJ459MJIPGS+uN4UxDnXNmt4Gi538CCDC Amww== 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:content-transfer-encoding; bh=/A98ENoFGQr2SCQn9ABBf4M5URnbGIlXVcItSyIlQIY=; b=okGLzs99uJLZdKoWoAKbLGFpFKid41ifYOdf4qpFqFgadgvvg1J+/nTm4hQtybW/zh zvtPrTl0bGzYstJfTw+LdMJKtdH3xx5KIxf0YKiFzn+4Azrz6l6OFCHLyhjuGZYgY73E VV8vQwZ1SpMqNUK6drKXS16tyWVxPDS9EJ5tflyoj37bnDXuuZOpNt7GTyYSNw/k775s tqtZYdvje6tyULp2G/A5FljSTaIgZ833K6WLD95AFJck10Hd53ctlTjDZut8PHheb1dw +cMZeBgiyIOwKgC26yGnmmxxz8JMS/bs7fSev/22W648IgAWHXWkrmIgf1Y543maIKl1 ErGw== X-Gm-Message-State: APjAAAUGWj9gRhlXRvI6r3tsvjvs4i5aK6Kkdk8bsbsE4BnXI5+2BpZx J6LdzzNHAsSHgzZyj3Hu0wYRznuw7JK4ffIedBq8qvlyfms= X-Received: by 2002:a50:fb0a:: with SMTP id d10mr84112001edq.124.1564646877779; Thu, 01 Aug 2019 01:07:57 -0700 (PDT) MIME-Version: 1.0 References: <20190729151454.9606-1-hslester96@gmail.com> <20190729191511.GB2023@amd> In-Reply-To: <20190729191511.GB2023@amd> From: Chuhong Yuan Date: Thu, 1 Aug 2019 16:07:47 +0800 Message-ID: Subject: Re: [PATCH 07/12] power: Replace strncmp with str_has_prefix To: Pavel Machek Cc: "Rafael J . Wysocki" , Len Brown , linux-pm@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pavel Machek =E4=BA=8E2019=E5=B9=B47=E6=9C=8830=E6=97=A5=E5= =91=A8=E4=BA=8C =E4=B8=8A=E5=8D=883:15=E5=86=99=E9=81=93=EF=BC=9A > > 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. > > > > Signed-off-by: Chuhong Yuan > > --- > > kernel/power/hibernate.c | 8 ++++---- > > kernel/power/main.c | 2 +- > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > 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= ) > > > > 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? > I am not clear about the semantic of the code. Therefore, what is the right way to fix this error? > Pavel > > -- > (english) http://www.livejournal.com/~pavelmachek > (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/b= log.html