Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp308422ybi; Thu, 1 Aug 2019 19:32:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0zqGsjcs0P87l4tJ5NZgtewIRl2IZPeod9b3v+pgLrAulKaO+YjHoc48W5M9Vg0OJ5zy5 X-Received: by 2002:a17:902:e58b:: with SMTP id cl11mr125657520plb.24.1564713163297; Thu, 01 Aug 2019 19:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564713163; cv=none; d=google.com; s=arc-20160816; b=FoQCU+S9X0jIBCAVOX+St4EgZHZ78m57lgz0RmCjF4tVj8UM4EXCeK6/oU38IC2utR 4fPoURCVDM0zGacGsAvo8hAJnX0AoojnlFa0J2cTdmFU7mdDpm58FjgVPcp/4rSMZPa0 WbjesSVVQ4K7KpqT9BCW29g3SKyS6VwziBWMYYbPxmQjP2gTyXWSNsTNV0whxK7jMjYi 2HDVCf6IJ2Eyv32vpGNK2My+v4VbAoEyITp+q7eMTmDGen4uK3CJC6E8QKBC+DoeCSac LY53HPxfAjmILmJ+Orrt0VXWGRHiNGMNFSuDq278UP3JBoUohUMLACWifCabvS7FONAK +OKA== 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=HuvGrEKDwaYDxNsylZRH3iXO6ZMXYnOP7mztNqR4E2A=; b=GswVx/b9KJuiiFErxfRUyXRPC6i8/5EVnbR7AYzkWbkZtPnfAP62dyHWCvs+XLW+kN 3yPCMYtO5M1m0a5GozO6+qXiw0hhh3sI5K3fmazVsjAcTU0o4inE1p63HEVzTDGEieVM 47PRx0hXauR/UKuGqxL35YMxFIde/q2NWWgFxETrgPLHT/47BI571VTz+2qigl1VKFwm 0pKr54eJZjNKmObob/MoSiDMoyOx22JDWUhseF5+p9zNh5I3k7TN/Qps2rotw2mTUcwh 94xub2bwFWKl2z9L7H0TPoG4DSp9AhPrL+bI84lri58By4apBkr2/qtBm9L54TjbaFsW y+pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="tP/9nOuQ"; 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 e30si37450015pfm.78.2019.08.01.19.32.28; Thu, 01 Aug 2019 19:32:43 -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="tP/9nOuQ"; 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 S2390641AbfHBBr5 (ORCPT + 99 others); Thu, 1 Aug 2019 21:47:57 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:38042 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727630AbfHBBr4 (ORCPT ); Thu, 1 Aug 2019 21:47:56 -0400 Received: by mail-pg1-f196.google.com with SMTP id f5so26375403pgu.5 for ; Thu, 01 Aug 2019 18:47:56 -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=HuvGrEKDwaYDxNsylZRH3iXO6ZMXYnOP7mztNqR4E2A=; b=tP/9nOuQALgghPmYXazr8/2p2rD1ahGSBrjFT9OAg2J9ptUwaPuknyOCQulWk6g0Fx LpbdhrNAahm6NsQif5PJ76o7KNrjqKSQAREjJEmsMvroMpBTdASZ9EE/3oo0+J2LkZoi dq4VMKhaZTEDcXbzmXCQbtgNpvR2IvME5JZLb/M7ASsNRWeXuJfgBB9jyQ71lFeq1r4d elZ0elm4LEdLsUPPnNn2nE94dKhfZZuey/6sM+0JUn3BF7lhMaozB49omj5h+5FFCGCQ RZsaYfkp+Jv9CMvFmO4QyAlTzPP+Bh4+c3xDccxa36mU+8DJq/i25gxAOw1T/LR4cmfe OIiA== 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=HuvGrEKDwaYDxNsylZRH3iXO6ZMXYnOP7mztNqR4E2A=; b=khz8CJZFarqoFrgIsBgmpW2sQJXplSjONyAxBap++HAhaddcD25sRbBWsTWrVcu8Nd K5JDmjtNlKsvP5Yy+SmgS+M507lMfYYCmmhtp97R8oDvWU/H3izSTsaS+SgQ6Pk51mg/ 6885UjcvqzTXN4YXIGCyWvjczYpdd7fDMgeWoUxjvyOgTKfawC+6tz63Q7NFqzePKDp9 mIk6pNPIb5S/fZwgkUtD2cenJZp2fRInt1MUE9dSZvJFFyM5ZVLSU5bO6dlKRkXwv5Lr /iKEDeNrj9/0Y17EQfaiWE135DEYPEniy7dCMBwIXqVkOrrLpR+z3mu8UZlMvjuSU6Mn 80+g== X-Gm-Message-State: APjAAAWWMFch1GrtGHeslDAMclPPe7EiKsYNW5NXD1P3n9LQLaI3ncFF ho8RcoT2heEc8uyYCsx2xxE= X-Received: by 2002:a62:64d4:: with SMTP id y203mr56380968pfb.91.1564710476079; Thu, 01 Aug 2019 18:47:56 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id p1sm78437616pff.74.2019.08.01.18.47.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 18:47:55 -0700 (PDT) From: Chuhong Yuan Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH v2 10/10] watchdog: Replace strncmp with str_has_prefix Date: Fri, 2 Aug 2019 09:47:49 +0800 Message-Id: <20190802014749.9168-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. Signed-off-by: Chuhong Yuan --- Changes in v2: - Revise the description. 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