Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7824874ybh; Fri, 9 Aug 2019 00:13:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGOLgphORAIKRzjYbcdVZEwS4hVp9tLSZ2PU01LI9zbje7uN3uswAX7lSTW2Gewiqr73Ik X-Received: by 2002:a17:90a:ba94:: with SMTP id t20mr8223836pjr.116.1565334832244; Fri, 09 Aug 2019 00:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565334832; cv=none; d=google.com; s=arc-20160816; b=E1Z8Rt+2rbDZb9FtcddGwJIOe/509fRrCB6chvmOUTJNP8bHRXwV+MiLYghBFxf9k2 EHdLiON9hYm5NhbRIGA/5N2NjqCON45xfwcC3hTL+QSA+FihO+J+FzekWoDb7E+QRTLU 8oryAvyTG96PUiXnH92XiDQDaW+7SZeqMNGF9cJQ3OMMRRY5GgxwFvLY0YcwUeZe+/Dn 6Itnfgr5Ekx4W87PQRMVmgBQxaEOOAWEfqwdH2mtd8u/EnW26Va8dxFOZXbwxzkM3fzF BKXN8wtxbPY2FIiK3rU62rhYGhPB42NHJep+1ku5dYpO/6X/b8A9OP9Ye5u0aMG9wDnq KRMQ== 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=EjwZNlktHghstpxixs3rvpStFdmZYyLz/JzoPP3gLRc=; b=rFaNyM8hXmd/QARTdDNw9XelZVDMPUxHq7NWN4ORUaKVQC9MPdbT0VJMLmDLgVokEW pgQIXUkfdFoYHm51BDRMPrjek0xjWMRuZBVMemX5TeYtolUZ9vRMwLjg1OSAufKh01uR tLBgq/i2rI8ApENWMRrnCoL9yx4ezj0etL/m8JuxgoaoiExMwto8o8SCEdS2aNKQwoH+ 4b4XwLDZzjBgmiuQwrQLkpU0Ooph15acV0WEwQTZW1oesKtwnRuoWwp0ldixaO977OFw mjJ2s0UR0C9xq/gaef4DLskyqdaGlgWc4fBfR+0AaFLg9sJf9DYXcDfZ3kvVIDA6AQPU NeBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=KQOagqHH; 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 j4si16956224pgq.375.2019.08.09.00.13.36; Fri, 09 Aug 2019 00:13:52 -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=KQOagqHH; 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 S2405809AbfHIHLR (ORCPT + 99 others); Fri, 9 Aug 2019 03:11:17 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35355 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405601AbfHIHLR (ORCPT ); Fri, 9 Aug 2019 03:11:17 -0400 Received: by mail-pl1-f194.google.com with SMTP id w24so44594198plp.2 for ; Fri, 09 Aug 2019 00:11:17 -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=EjwZNlktHghstpxixs3rvpStFdmZYyLz/JzoPP3gLRc=; b=KQOagqHHx1/8wVn2eGgM9qF1OnlzjsplWUmA0IrMsWeS7N05lMCyDGlo3aIdoGEVOQ qk/DYh5a1sv6ID7/o25lOJbzCFk9eGxFOSxwwd/2w8NvnphRK96MOkD/PeWk8j7dznXL xXwSEkSod1tfb1YBIhx7WJ18nkcVYWSD1QLmuH3VXfv8d/aUFmhSF0vu6jwzo24EWzSO 1wukn1M3lTG23xpTd6mqAMmqVxmFSdAMJr+iZGR2dboMe+SkVDdbxGrgGUCIG/Ee1jRG gBxMWlr0A6oDN4GkzLrPieSAYYkeGlu3VgZImnqGbQUOp7DNsL1sAKztqipW6kQegHzb a0Wg== 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=EjwZNlktHghstpxixs3rvpStFdmZYyLz/JzoPP3gLRc=; b=eqgwsyOGPx8b9X3jlGhUMKtSV3ehUPtGJAoK5AkwP9p4WKi4EGxirFGv2xugSMh7Uw hPOpt0qOnXTR5+VhfI2fdKbRw59+AWOCTV/UvRl5VEWupJ6ZI+TJ5WugtYxisnOG3SuD hl5swMqaMwr7ZhLf9ZEb98b89lZyWlGuf5y/EghdeZwwLbB4z395BRe+eRj80rKUAwRR F/OJ/gFupKL2esG2OWYPhSnoAo+YUCqUHuqTeSYxRm71AG3j+9L6yP1zkkIflemhgR+P +848EgHhZrnLh0Xg3GaLXRFssqfkkUeGXmGd/G9bbkWGT1VGmK7H9unrHiw9XWtz/uGa w9cw== X-Gm-Message-State: APjAAAUQIXznCuf+mfL2t9Z4Gqs13+VxGpBwyWKpbvC6rLzH8fePVm36 ERjyKYjUcJzbKPkHia9TeXvOn/goDMUJRQ== X-Received: by 2002:a17:902:461:: with SMTP id 88mr7653273ple.296.1565334676707; Fri, 09 Aug 2019 00:11:16 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id a16sm105506801pfd.68.2019.08.09.00.11.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 09 Aug 2019 00:11:16 -0700 (PDT) From: Chuhong Yuan Cc: linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH v4 8/8] watchdog: Replace strncmp with str_has_prefix Date: Fri, 9 Aug 2019 15:11:11 +0800 Message-Id: <20190809071111.17496-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/watchdog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 7f9e7b9306fe..ac7a4b5f856e 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -70,13 +70,13 @@ void __init hardlockup_detector_disable(void) static int __init hardlockup_panic_setup(char *str) { - if (!strncmp(str, "panic", 5)) + if (str_has_prefix(str, "panic")) hardlockup_panic = 1; - else if (!strncmp(str, "nopanic", 7)) + else if (str_has_prefix(str, "nopanic")) hardlockup_panic = 0; - else if (!strncmp(str, "0", 1)) + else if (str_has_prefix(str, "0")) nmi_watchdog_user_enabled = 0; - else if (!strncmp(str, "1", 1)) + else if (str_has_prefix(str, "1")) nmi_watchdog_user_enabled = 1; return 1; } -- 2.20.1