Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7822635ybh; Fri, 9 Aug 2019 00:11:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7p+VR6iUyVGshM+Y77oLPXR0538bt2PGF4MyySGFmuodkXfFvE3OXxy6SAIi1LxXWGLfB X-Received: by 2002:a63:ff03:: with SMTP id k3mr16556198pgi.40.1565334687093; Fri, 09 Aug 2019 00:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565334687; cv=none; d=google.com; s=arc-20160816; b=axvvF0XWSvsFbVoE8KdSVXzBPJ6J8/J67pawF68AAfZGTm7LgZ5aLleyNtA5W3xv/O 8gscLXY99MQQN2ulsVXyanrkD0PUkx1drVsNdfMSl6zgHFCmVpVTWRPLRBLWIUKugkSo VjzV3+8i0r+gFfYIvbGtk1LwGPY5rYJ3P6beoduReaFmCS5tzZ7+7+BcMOhbKlK1duzf eTQ7aYrHJWeB5c/gXdU8DnrO+VnFwipVm/1kyjmcHkKNyP+Y1jbL4CYeDQCDpkSSXoYx N1tAWlOUXnNpLBKrxFKhsa2fs7I/c9QdjVPmfxpi97xCw2TGTfX0i4BcMLzUuISyuvSB Uj9Q== 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=gHnPOS8Pm8ZeyA7Uap/VGmk8/SCT3qez5bm05fI/Eqw=; b=dYGEdPQ1E+jAO5dJKoiZ8hxYrVwkCxe1SVwzZ8TPVKlcWd91tjrcvoJukznFlY/3S/ 7E4RvuISAwz/GsVHSIoT7vkOuZKEptyHcbpHqejXvGXJNQyS4uAGEvFOdaAh8U4CZCKV 9TUyB9C9hZ+McbJB3D5msj/GsNkx/CrwUI/WuQ+Qr2hR2tZ+PfpizHv964m6BmYtOHrb QIGqpKPeDWcINGUCXzDIUyzyTZQCv+85aV98Nm1meOQnRI9cUjFKX+inWEUCj338ZW/Y ag4CDLE+sj9aI5uUifMnclU5sQch8QUUGZOqdI4RhPJncFundOdEf3eztia6X/5GembL lYHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=prEg84b3; 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 y19si52806878pll.326.2019.08.09.00.11.11; Fri, 09 Aug 2019 00:11:27 -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=prEg84b3; 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 S2405737AbfHIHKX (ORCPT + 99 others); Fri, 9 Aug 2019 03:10:23 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42620 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725954AbfHIHKW (ORCPT ); Fri, 9 Aug 2019 03:10:22 -0400 Received: by mail-pf1-f196.google.com with SMTP id q10so45526382pff.9 for ; Fri, 09 Aug 2019 00:10:22 -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=gHnPOS8Pm8ZeyA7Uap/VGmk8/SCT3qez5bm05fI/Eqw=; b=prEg84b3JShuJLqsV9dW/+P4oSDBYOxR5bB92u+ngwNZSS7zuFYv1AwkKKkjxA3nwE 83uNgiJ7dEccJcRec7gye36J2u/8CXKE0qp8/YC7ZPKg1avZ2exp/va7iJFp8dPlwDuH G+pURNTYyDVTZrPo2Qy320dJVSDKrpmefK2ocXr8QIbeuCixmXL1gpOMsuKWGi1U/Xic ewYPER4JIbbXHiIPfLdm1gQK2CmuBIL8vP7h/NcNtI28C9xv6vahwgxDYszjD13YcTL/ aCcc5Lu7up6gaeFEbXjqdGdcLSZIGDfgxxBvyKFIWLBCOnhw/Qchmby95BN7KhOBKMvm Kkhw== 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=gHnPOS8Pm8ZeyA7Uap/VGmk8/SCT3qez5bm05fI/Eqw=; b=N9u0fcFOrbWMDauDzOA5OyC7FaGqMMGLx0VIKC1iQ5a6HMDOzcyLGBKElDw0+0rcVm 2ivKLYdS2DgDb2+6ycranwkvHkB4s4iYrym7nBBXXaU96PnJm3pnyf55aED3sFtDaEhH JS32L9krLJl850eikJZCKkRlZ7sKMf9o8z6FxkQnIvbs2Y7dLDKGPyRW2MJjnJXfQfaI QEeJEalG/uuVTo1VNT8VmdelF4rF4BgO0Nqeqm82/eBmrvcUOhDh68Hqt5veAxHe7iRI GV8R3riNiCN/RArWmqYYbUXYDoJNRftVOgfL0VwpNHh7sbCY5fv+synFL1Xlaylvy4sX BnSw== X-Gm-Message-State: APjAAAVdX1zDJi3SlHHcWa+8/sB3hUy1WZpwbEL845ykbLizBFPrWWog tyF7u+4HQeyT2kjMBFyXrUQ= X-Received: by 2002:a63:550e:: with SMTP id j14mr14561266pgb.302.1565334622328; Fri, 09 Aug 2019 00:10:22 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id h129sm92145915pfb.110.2019.08.09.00.10.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 09 Aug 2019 00:10:21 -0700 (PDT) From: Chuhong Yuan Cc: Jessica Yu , linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH v4 2/8] module: Replace strncmp with str_has_prefix Date: Fri, 9 Aug 2019 15:10:17 +0800 Message-Id: <20190809071017.17170-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/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