Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7860805ybh; Fri, 9 Aug 2019 00:54:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbuUdWG5/E/CwAha/h0AyUy0CI6xeYsFMe3uIWvPiV59d5deRlMfThwmjlpnmIC0Wx6GRP X-Received: by 2002:aa7:914e:: with SMTP id 14mr19945748pfi.136.1565337256975; Fri, 09 Aug 2019 00:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565337256; cv=none; d=google.com; s=arc-20160816; b=mJny1eNrwBSrfkyJIvlOZcE9WPyZ6ErZ9/+njTmFJi7N97z/dmZw+fl9jpdROa9cXE fgMg+JxpD3k7FC2XisVZSJLbq0+4CtbeaxN5ehFsu2w4nD3Hh5OwDXwI1iJkUiox24wB 3EVhawKxJiG4bzkU2LanjS4aLYBhtgq7g2PW6ly1QTdhHW6oTjZfqdF07QXwiDhAtVuy GFJh6+a+N0/SsE6Jhi/4l2thyzyHrRa/sL08a/igy5BUFV22dYO597o5D0Kk3XI3QZ+k 6rDMO494LGSrEo49crXPzdHshK131FTXzBJeKOd5IWlITIvGmMFyEJ39hrAz5yclXSuu xvsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=AfFInu/BKl5gok1YyMJiKglvG/hgOvmiC2oJHUZbiVA=; b=lc8ic0p0t70GMfjE6KEhyon2Tjvbd4LMdgfWbVAajcyEBQZT8Pqg1RBWa3asGFvyf/ ujOFWarDjFBI//cCTnAg1gmHvzxV+CncsM08ziM+0RvUeu2fSR0/MItqPxcj7LeOG29v GwkiXo3XYdGG1afIM+5A1xdHGB0/ulZ2XCIu/VoZirjozQU7w5DEhNC/T7nJ/oKpmGfg x6cAWNVccsWMvzVi4fkm2WK0RzwukNVCitcQthM3dGEv3Ja29A+IXNu8q69g12UIwuqV bx9FtSU26DMlG8rfBIuMzdrsw3i8pzshV2xJfgEjNuHhXPu+I0G07Xlh0Z+wzZbUosId 8Yjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qnGtnDam; 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=fail (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 h98si49151239plb.206.2019.08.09.00.53.59; Fri, 09 Aug 2019 00:54: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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qnGtnDam; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405724AbfHIHKP (ORCPT + 99 others); Fri, 9 Aug 2019 03:10:15 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:36122 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405239AbfHIHKO (ORCPT ); Fri, 9 Aug 2019 03:10:14 -0400 Received: by mail-pg1-f193.google.com with SMTP id l21so45390767pgm.3 for ; Fri, 09 Aug 2019 00:10:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AfFInu/BKl5gok1YyMJiKglvG/hgOvmiC2oJHUZbiVA=; b=qnGtnDamMWxXkDvOfVvqZyiG6ESs3LPrdiIFipKW0wSvRvybAaPD6u37c/y+Acoxl5 WcyXF6qUzNvxq9ql7r5zVsKIrKNF6L629QOCJF+cMyfo8LL+m4L+kas/k9Z4REFndMw9 Ma/5yipfNJ0LrB5NNa4xGgCzqc3BNHGZ8C5CBQ6nKC5fULk8MJgDqoc6WSVQMGUTLNIi RWKkW5eTgoovXCx8d2pLjD4muWZYJdK4s1gfk+sDHLMVec5Zam0ER72GybKZGyuhS8KD W8ovG9Oe+OzKUSVXog6pgZmJDGg26HIq7jDbIxKADkCXHo0pjEpkXFluSrfOGAjLTkPv H4xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AfFInu/BKl5gok1YyMJiKglvG/hgOvmiC2oJHUZbiVA=; b=E3sv1wYDqfcYec56wLV4GPG697MMsWQTxIE7xU8o/xiMgmTSX6mH0lMoH/q9iCBktc b0Q31Wg01Ofej7kzoxmq2Ffa5mw72q2/RO7Xzjfugjg9nJcmKfMgAKXtelSF3qCmjOFm 3TUS75LX79trgw3leBZqZL9Qmmd2Hse478UCuqsCrFKhsR1HAAWHjv/79ww6sRlSTa4N IsOtW6bfUMyWqYTBlE8z8qJH3wHeZDI1BZAXOt0InmCzRPQfBxaDgD4EGDBZQt+no4Pw 8dDBfdqdHgNlHZVIOe3nYZ860k+gTQFAupZtaA8za9PRPAiAVep+5UyJjcmnr0mBWJIR xBhQ== X-Gm-Message-State: APjAAAW4iQPRXr9SMUhudrg3EUmvWo5q8MbKjSgkQ/CRR0kxTQ5RO1mG Z45ZsB8ku6Zm+yK0w0ADzXA= X-Received: by 2002:a62:1444:: with SMTP id 65mr19563170pfu.145.1565334614339; Fri, 09 Aug 2019 00:10:14 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id w4sm120886334pfn.144.2019.08.09.00.10.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 09 Aug 2019 00:10:13 -0700 (PDT) From: Chuhong Yuan Cc: Christoph Hellwig , Marek Szyprowski , Robin Murphy , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH v4 1/8] dma: debug: Replace strncmp with str_has_prefix Date: Fri, 9 Aug 2019 15:10:09 +0800 Message-Id: <20190809071009.17114-1-hslester96@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/dma/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c index 099002d84f46..0f9e1aba3e1a 100644 --- a/kernel/dma/debug.c +++ b/kernel/dma/debug.c @@ -970,7 +970,7 @@ static __init int dma_debug_cmdline(char *str) if (!str) return -EINVAL; - if (strncmp(str, "off", 3) == 0) { + if (str_has_prefix(str, "off")) { pr_info("debugging disabled on kernel command line\n"); global_disable = true; } -- 2.20.1