Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp307709ybi; Thu, 1 Aug 2019 19:31:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzi82WG8+S2V+SZ2QNB5bvWkJAu71e2UeABSsSOOm5/em9+HvBJHcCV73gsnnIXwWeS8LcJ X-Received: by 2002:a63:5b23:: with SMTP id p35mr9917831pgb.366.1564713115910; Thu, 01 Aug 2019 19:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564713115; cv=none; d=google.com; s=arc-20160816; b=wPmX6JclH8iqy/czm+q11FaZuZdRK34hhW9Y+gF+45Fmymkozqt2YROZJBdssIOU01 EL8FRnpcfRNhiFqDBNLKkTs+OXWQiJeOZkYFBnma/JdN0klKi+EVXglXZRbkHkPjEIXU yq317CIYGQPng9q8Aku8azk6D4xoyyU6tRNSuL2JYPyV/JKMtQr78pcjccz95abt1H2n orzdC4VLS80larSW6FtuL31DeMdarEVcjWmqR7sgV/Eeqj1fFZB5+WqvpHHEtUIWsy+6 +etNPnYAS7q8Y25lAHuEdDpDXpMwq0Iw/Vez5nrZvYhcJt+2oQ5EZiy01iwdA98aue4n EQZQ== 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=HJYoXfP1sld8oyBvXEQKsOFywLwHaVUeYYSFlTyLW0w=; b=t0US2G0cNeTOT1khaABgHNuWH81CUSyNBRrAxwHHdcNrJpOWGX0cjBR4xU92q4oLnr SnESA9qxDKU7sIyi9k+MqG9odGsCVr30sL9pgLA6EWxOWf8uXiU3lRQJ6lWDdv2OZa16 FX1xheV7ej31y2CKTVhRhPyW6N98OqG+C+yMRIuc1BlmxLAkTC0a1irZxaedJen6xp0L He1mbZRqd+Z49GR7R1nqr4GrvdhNTDC/5BRUtZDkkeWzLtntIJgQsJwJqSup3ZYwmfC+ gLOqvtM7ugUUj2iFmY99hxwwN0rg0O5V4rau7QWsmUgDzVb9c3mKYBzmakb1LZDn4sKD NPBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=L2pdqvmr; 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 8si67761027pfv.149.2019.08.01.19.31.41; Thu, 01 Aug 2019 19:31:55 -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=L2pdqvmr; 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 S2388801AbfHBBrJ (ORCPT + 99 others); Thu, 1 Aug 2019 21:47:09 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39260 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731827AbfHBBrI (ORCPT ); Thu, 1 Aug 2019 21:47:08 -0400 Received: by mail-pf1-f193.google.com with SMTP id f17so31115069pfn.6 for ; Thu, 01 Aug 2019 18:47:07 -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=HJYoXfP1sld8oyBvXEQKsOFywLwHaVUeYYSFlTyLW0w=; b=L2pdqvmryJUIlSeZim+ADKnKE/zor5HY5Uz992lsc2pWXUUATZJ4gIw9YuZRdhWLd7 CBjjYuhRYwe8DpSFhqGjZha4PApGyQNDy+BiiF0ytexD2JGFgVbmz/heBLdBOqeAO7J/ HQDCiHAS2t32YoHM22TMAokv6XpzkTpVGMEz43c5Se4qvEVp1lKt2jYkktw7ubYMRIsk IJcpyyOFcB2WeXr1g2Cslh6X4I5Mfnle9UfHtG8FN7NQNH1OzspWnuGqBVanrzOnnrTx 2Yv1eVmlWIcCW2FU+apEGzEJnL5M3rbXrFBggqE7+TUds9MiJq2YJBWGTfzoQ3i92Ax2 lofQ== 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=HJYoXfP1sld8oyBvXEQKsOFywLwHaVUeYYSFlTyLW0w=; b=nAOqGIL1+nfzB3535R6nngLQXm96sMfLRKqxafLUj05owVSFx6oQyEhi1WuN5MOzEl 7OF2U3hPAdsCuG42hXw9CCu1VwGxrsLlYb46NClEf6mhnnofBQJ9sGOiFl4ZMZzYoN7k InZYh62m/FGTjeFLB9/wRXxkuJpxnGFDuClUUl9EBbntAriWXcOaKwahtuXyHIpcfQ9c sjpJd2d9uwko88agm7diIoSGMI+JvfXB+gbMicSQr8jTBDlX6qXyee1ifrMtXCkpe747 EGWlSetLDx0OJ8iXS28qrOBbLRwIGhKcR21DQqU+Q8NxaS864+qPwxX0unijPHn343MK XFuA== X-Gm-Message-State: APjAAAUmUhVd3Kzp9BfyQzNct/voZYSCq57mUlzq+3k1DRUMn1r0fEvf 1ysnABg+arbz+UphaWcvGzaC3lzewE5jlA== X-Received: by 2002:a17:90a:a489:: with SMTP id z9mr1750798pjp.24.1564710427209; Thu, 01 Aug 2019 18:47:07 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id p2sm100657606pfb.118.2019.08.01.18.47.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 18:47:06 -0700 (PDT) From: Chuhong Yuan Cc: Jessica Yu , linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH v2 04/10] module: Replace strncmp with str_has_prefix Date: Fri, 2 Aug 2019 09:47:03 +0800 Message-Id: <20190802014703.8844-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/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/module.c b/kernel/module.c index 5933395af9a0..7defa2a4a701 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2251,7 +2251,7 @@ static int simplify_symbols(struct module *mod, const struct load_info *info) switch (sym[i].st_shndx) { case SHN_COMMON: /* Ignore common symbols */ - if (!strncmp(name, "__gnu_lto", 9)) + if (str_has_prefix(name, "__gnu_lto")) break; /* We compiled with -fno-common. These are not -- 2.20.1