Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2696319ybh; Mon, 5 Aug 2019 05:23:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfrEd/2LOReRZ+kmm5FaBers2n5YqvpAbAIOo+OmhNH/iZ4eyRl8jomy6uwr0jhnxCwG1p X-Received: by 2002:a17:90b:d82:: with SMTP id bg2mr18235397pjb.87.1565007839388; Mon, 05 Aug 2019 05:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565007839; cv=none; d=google.com; s=arc-20160816; b=jvwjj81q196RkRqKi2A1AQBgnBDqu3Cx/9gjsxm57MrzTzh5AdbQCPoD6e6egK+OO+ qVz+at3lNfpF9cZ1puF96pnn49mCS7y3yeco00v9kS9YFCLad/IY4jVXFG/W9Zj7XkMn /wGNF+OQhWLy+xk69yfafgmyj3sBMXTfZ2m4oAh8OF9px16hBhD9lViZAhkHoebC0azy U4V5b5dzuox04Ti9GQI74xoc2TNtbN8WvZAJpEA6t+Pjyqv4Qk9epaevTlFSlOnXDcRP Z2tsSJNedNqmD6frOQNJmTMLCvOpT7D2twEO9Wot0l3MOxFN9nBLS+tVDJswPDvlsmcz 8RpQ== 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=W4dmv+a7M10+vcMcRGJokNUoylYUqcGnL45osAB1FuE=; b=G2/o48Id3JzXIrFK+KWE20j8Mx59DXS1wJt5ml+r55aNUt0HeIX/kQJXGGq01mtuba WY7hGWFempAfCb4DYnJpoqAvYV36xYOh9T1vGfWl7sZhiIuiMEIBbVB0fI7Fa81I3DEI A20bRyCunwwe7k1MNaEP8NMj1utPE4zT37D8bZDQ3R9qAzm3rRUVVXhURFBUHZt/2bZ8 yy5RnCL+17B4LiQDfCtmcVLoaJuvhFdF644Xb14DTV8PbLRwYbgAqRyZgFQOfT7uDxpe /bFo+WM7RR7BCQRypwGq8IjFud6pmj3RwoEjMS9nuFE0wh4vQ3SlcOOGGo/0So400e0u 7zAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=jtpyPKBE; 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 d34si40998856pld.54.2019.08.05.05.23.43; Mon, 05 Aug 2019 05:23:59 -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=jtpyPKBE; 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 S1728701AbfHEMWm (ORCPT + 99 others); Mon, 5 Aug 2019 08:22:42 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:42571 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727259AbfHEMWm (ORCPT ); Mon, 5 Aug 2019 08:22:42 -0400 Received: by mail-pl1-f194.google.com with SMTP id ay6so36457743plb.9 for ; Mon, 05 Aug 2019 05:22:42 -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=W4dmv+a7M10+vcMcRGJokNUoylYUqcGnL45osAB1FuE=; b=jtpyPKBEVrMUIfDD5ScmDJwXPy1WGC6QvtVv3lgtPxU7XVr9sai//cOmH2ONrRAQAX LSuZ3w5N3daJWEsEd0tXYZ9uRQB0BiNj7MvocZ5K+UDJxwftxlehae0/lB+yJ8B7HR9g uB3aCFljol4mrXt52dvhqbb8UK0l9nzpy3Z7VVJCbDuPjdFgkqFuZzygJYhYJDcvNox2 6qBBXrzYiR4znXUO4mO6xidXqqFK6t551QKvxLDj6PJg4iHxr4SXbbuOqKDGXhvHgxhb 2wuHZU3lUFnu5pAKWe1U5GG9a99X+YH1PiYzPNqk5FeOTmA7ZNBEZ7IuOnrefu9LezlM W9eg== 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=W4dmv+a7M10+vcMcRGJokNUoylYUqcGnL45osAB1FuE=; b=AuMGlM2UQcFEMd3FVBy8EzmI8POmb8SpKA7FZKm8COFBfjUU+H/EW0N5Nh+VvNBoIq hgbwOO6the/aEGagFkd8DiTrEVn24IVQDvZtkUhN9DKLTdafoGQweXHNVtOZWB4qqWxO U9XPcQP10FuVUDzg2quMt1wWKjXy1BZHUWA/ua7IP1j8m2DYWySKk+d0OCm3aNRf7Lun lF1H2fWxyzxk+rdM6PdkvROxQX1DO+36Z0/mk02uzlcDyCD24m9O8WZFZVAEHNhBBi1z Pcc5VQ84LouNHapdmPgvPC3E8cZ/lD0PfYTYXXvFaTkb71jImWOhcXGufgaPZ+u5WrFM Iw3A== X-Gm-Message-State: APjAAAWDlesByBUNl4Rp9C9WR/nH/C2kk364rMy5vqxyJ/kerLhuP4Qo GqAEcKaukNpX4Aia+jsq78UFOG0grKkNKg== X-Received: by 2002:a17:902:934a:: with SMTP id g10mr146699397plp.18.1565007761834; Mon, 05 Aug 2019 05:22:41 -0700 (PDT) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([89.31.126.54]) by smtp.gmail.com with ESMTPSA id u134sm81795363pfc.19.2019.08.05.05.22.38 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 05:22:41 -0700 (PDT) From: Chuhong Yuan Cc: Jessica Yu , linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH v3 2/8] module: Replace strncmp with str_has_prefix Date: Mon, 5 Aug 2019 20:22:34 +0800 Message-Id: <20190805122234.12932-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 --- Changes in v3: - 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