From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A2F0C0650F for ; Mon, 5 Aug 2019 12:22:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4EB3920856 for ; Mon, 5 Aug 2019 12:22:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p6Z3kfl4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728597AbfHEMWT (ORCPT ); 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-Google-Smtp-Source: APXvYqyKEfTE85E4XHkXoQNUJWBl4w/9gg2ux5fA/09qhCairbUTm2pP4GaeK6Zg8ntOYFTPUxt7kQ== 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