Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4017953ybl; Mon, 26 Aug 2019 04:18:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqx29vZ7+fwryZ/mCZQXpQNHV0fYRC3QLQ70vaEjhZrLxtH0vPAhtipQGuIR49KV7hKE85Fk X-Received: by 2002:a63:c009:: with SMTP id h9mr15874202pgg.166.1566818296578; Mon, 26 Aug 2019 04:18:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566818296; cv=none; d=google.com; s=arc-20160816; b=dXTVYhx/fG7EF3VVQSJLf7cZtyG3MtVtVXJYxMLsgZqbjo3qxRxF19jYqAD0y7yLOB s77/kSJCyG7XeraXLWBAKmHtfrIN4g7HrJrKVTqKSQnFjqook8ldkb8Aiw9eDBKKmMTg +ryK7VQ2VfPiOJ9Awn+i+aoL0Z+Nn+0ByXk/0gDWrZ5uL4zHY+j4cvXGak2HRNOXxVz4 debk35888HLWipJa58tUukctQfvLlI5pjND6d4bRHYZcrMGmfbi1AirwcxiStrcfwRGG BKcvC+iAUpD91Sg5IfbO9IIQUkUW1OevNuKFBKFfqBL0GXFEgQyUcNXN4NGy3aIv1GG9 FPKg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Drr2TuAgb0yhIcVv05xJMECtg6EmlGpwRrU46BX80kk=; b=FjQIv45SydKpjO27qnv+LylJphVZgzSz7vu8AjWw4E5Orl7zjW2SDFBnyf766enpjt EON1y4sJuV1KuvX3dBC2VthQOt//r8JRyMAAfeCAud1zaWit1yLByZr3o+xN54RX2NJQ RicIxDi9O3ZcLI118pLElLfzYJtupSUVU9z/02W58a9WnydBEEyZGZ4qpD/OAuH99Tl3 HFB4ln4vyOZftb0bJMoxDeQ+NLPVb9VAgIHbPaLFl6rUHcXnjlAV80mO7yKdtMUMHZmd eSf7iFN9EhtB1xAQ9y+XtkZsXrHlq0QmGuqr3u3aWuMt3NUK7gcSSFtthBFhyOTKd34A DHAg== 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 4si9905359pfg.55.2019.08.26.04.18.01; Mon, 26 Aug 2019 04:18:16 -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 S1730865AbfHZJTP (ORCPT + 99 others); Mon, 26 Aug 2019 05:19:15 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:41951 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726354AbfHZJTO (ORCPT ); Mon, 26 Aug 2019 05:19:14 -0400 Received: from 79.184.255.249.ipv4.supernova.orange.pl (79.184.255.249) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.275) id b85cc94dc3460384; Mon, 26 Aug 2019 11:19:12 +0200 From: "Rafael J. Wysocki" To: Chuhong Yuan Cc: Len Brown , Pavel Machek , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 3/8] PM/sleep: Replace strncmp with str_has_prefix Date: Mon, 26 Aug 2019 11:19:12 +0200 Message-ID: <13649784.SkF4frceZu@kreacher> In-Reply-To: <20190809071023.17224-1-hslester96@gmail.com> References: <20190809071023.17224-1-hslester96@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday, August 9, 2019 9:10:23 AM CEST 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 > --- > kernel/power/main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/power/main.c b/kernel/power/main.c > index bdbd605c4215..5e5f64bb3a43 100644 > --- a/kernel/power/main.c > +++ b/kernel/power/main.c > @@ -495,7 +495,7 @@ static suspend_state_t decode_state(const char *buf, size_t n) > len = p ? p - buf : n; > > /* Check hibernation first. */ > - if (len == 4 && !strncmp(buf, "disk", len)) > + if (len == 4 && str_has_prefix(buf, "disk")) > return PM_SUSPEND_MAX; > > #ifdef CONFIG_SUSPEND > Applied, thanks!