Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2695548ybh; Mon, 5 Aug 2019 05:23:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqJe7X5fALsJ3M5Nwf8DlA6HoFYjU6XDbPOHXoQHWdhyNSt6142lvEnshlNu/3fYzazkpo X-Received: by 2002:aa7:97aa:: with SMTP id d10mr55077916pfq.176.1565007789881; Mon, 05 Aug 2019 05:23:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565007789; cv=none; d=google.com; s=arc-20160816; b=OkPZiJIaODcxH5L0E3mpR6i6adRw8CoGVXF+CzzCrC5k8Qg/3rwpoeDJ82jn/fRkLi 2M2nXmqt/wPCGR/nD5UTiN4B0B70aZiClGSVVXD15AzqEXCOz+XLS+WfRqbkr5/YkH9c +xepwMFc2tDS5Jh0oDdODbPTDoEawumm5u4owPPbxoPvIlmgCrgm4D/k2BtMOqMFZ0T6 AgR0gJk3n1PSISh1LdPDGaV2m4qlw7YVLnrMMfoA/MdSphU8mBrosFYMPJFd2RS7IRDp VGACzSr4EhcxPBCFfv/a0IhjIlHJIp8aqNw5WIbv49z9SP6rYfByf/R6hkmHzvUDMATB z/zg== 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=vEWoK/ncnnL5HeoDBfuY5M1+24Qlh2DA31rCewI/52E=; b=q31saDW+IBvADxXwmw5Lm2Y+xcy8NTjmim3s42toruW1hbsVrVaZ+TE3H/omJpO8ji 4FqmnZE0txFSEtegVIaUnuimYWNnESgUPqP0qxs23KDkol5Om2Jvv3TxcFbL6FTvCqhp SKviVPrkH/rFT6u1M1fAHvQ2naD6H19eyTsi14sIc2RxahrOHJk2ArZQLb/Ua+qXxezi qKYNsbu1UihLkxXoGptGj11XytO0ZprIh3QLwrNbFQJRrlOYf8P5JPE+Jw5qCh5q/bhw 3QDCsvZYaUW7s/DwdvP3mUwEgIgcjnpi7cBYtwSjre8szFQ6SfF/ELKi/WLa68KvTtAr 0aZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=p6Z3kfl4; 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 33si41736605plk.225.2019.08.05.05.22.53; Mon, 05 Aug 2019 05:23:09 -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=p6Z3kfl4; 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 S1728513AbfHEMWT (ORCPT + 99 others); Mon, 5 Aug 2019 08:22:19 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41924 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727259AbfHEMWS (ORCPT ); Mon, 5 Aug 2019 08:22:18 -0400 Received: by mail-pl1-f194.google.com with SMTP id m9so36281705pls.8; Mon, 05 Aug 2019 05:22:18 -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=vEWoK/ncnnL5HeoDBfuY5M1+24Qlh2DA31rCewI/52E=; b=p6Z3kfl4eEvXmrZiU9Y687TE0tfxSww44x8bZWTyiuM1Kk4+Ls0NTJ67ignEqCsb8V qFoXvj+B7+OYXH5/sjVkWdJMQWfVVVxqkBrItVYnnYbjuQruh8Pd55RQm7Gf3vIwN4pj qvFF+yNwQbDj6TRhMxwvFnYifcpkdEi0xX3oWKOj8LdlE6VWvZniE5rgSbC33RSHiq4p 7ji9b3MO2QrjgFvyBkTOmN49Uh9HswzgDWNIntCDXWJkN7bXuY50icgNCxMwWIO5O1uq QDRhnwKy2BjH/9Q8ZEHjRSSsJ4pjm1yh0yC14L22KF3amQ9pxCsB+WlNpVLLiEgmX7It MkiA== 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=vEWoK/ncnnL5HeoDBfuY5M1+24Qlh2DA31rCewI/52E=; b=N9W5HPJJ297AYWdM5eOJqTaUXyFm9kJdiLc9mcYtbErl/hoMMicZojooQ6m/6fGFSA uZ1go1CjdHMhw/87cQvJdwDqXjbKBdaivkX1AGAEt6wKz72dF4RZZfMEwnrXFatPAa4J brKm4mI+Fd191YDJyF5jpMvj/OQu5IW08LpNK9mz2ZSclugJ7Aa0k8h6BowWlES0vDPe GRvFoJrA9FVvMbrsRQk0DsdojYOBbb0/nBi+McO7s1cVhKdJMU3WnJA7uET8qm5nvJoD vLdUzThvhZylc1frWuNQ7YOtCYfgygSkz5mveppbDXTncyuPCNTIfdjiDJDhnnZrTTaF mmMQ== X-Gm-Message-State: APjAAAUW+rYMai3yN96EcMV3a3RgYVnYEeWT8ygBws+DyZrO+FmlKYI2 rU0DNa8sFURT3Av52OWsHyA= X-Received: by 2002:a17:902:8b88:: with SMTP id ay8mr139369488plb.139.1565007738273; Mon, 05 Aug 2019 05:22:18 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id a16sm92646276pfd.68.2019.08.05.05.22.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 05:22:17 -0700 (PDT) From: Chuhong Yuan Cc: Christoph Hellwig , Marek Szyprowski , Robin Murphy , Jessica Yu , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Joe Perches , Ingo Molnar , Peter Zijlstra , iommu@lists.linux-foundation.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH v3 0/8] Replace strncmp with str_has_prefix Date: Mon, 5 Aug 2019 20:22:04 +0800 Message-Id: <20190805122204.12823-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 The commit 72921427d46b ("string.h: Add str_has_prefix() helper function") introduced str_has_prefix() to substitute error-prone strncmp(str, const, len). strncmp(str, const, len) is easy to have error in len because of counting error or sizeof(const) without - 1. These patches replace such pattern with str_has_prefix() to avoid hard coded constant length and sizeof. Besides, str_has_prefix() returns the length of prefix when the comparison returns true. We can use this return value to substitute some hard-coding. Changelog: v1 -> v2: - Revise the description. - Use the return value of str_has_prefix() to eliminate hard coding. - Remove possible false positives and add newly detected one in upstream. v2 -> v3: - Revise the description. - Remove else uses in printk.c. Chuhong Yuan (8): dma: debug: Replace strncmp with str_has_prefix module: Replace strncmp with str_has_prefix PM/sleep: Replace strncmp with str_has_prefix printk: Replace strncmp with str_has_prefix reboot: Replace strncmp with str_has_prefix sched: Replace strncmp with str_has_prefix userns: Replace strncmp with str_has_prefix watchdog: Replace strncmp with str_has_prefix kernel/dma/debug.c | 2 +- kernel/module.c | 2 +- kernel/power/main.c | 2 +- kernel/printk/braille.c | 10 ++++++---- kernel/printk/printk.c | 19 +++++++++++++------ kernel/reboot.c | 6 ++++-- kernel/sched/debug.c | 5 +++-- kernel/sched/isolation.c | 9 +++++---- kernel/user_namespace.c | 10 +++++----- kernel/watchdog.c | 8 ++++---- 10 files changed, 43 insertions(+), 30 deletions(-) -- 2.20.1