From patchwork Tue Jan 9 08:30:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 123812 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3750599qgn; Tue, 9 Jan 2018 00:33:11 -0800 (PST) X-Google-Smtp-Source: ACJfBouNI1Ak4r2F4UE5jRv0zwSPwQhTJV8Vy5nMFrioVmbj6s7lOiN78rU6oBj1DXH0NfsW08+w X-Received: by 10.159.205.146 with SMTP id v18mr14913701plo.25.1515486791530; Tue, 09 Jan 2018 00:33:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515486791; cv=none; d=google.com; s=arc-20160816; b=K17ZPg7K3KHR8yqDYEYBgbPuYVj0Wl6qwqo7CkBaLscHnH1SbQqtvvqqHYiUWgs7RK bTKsW8apMvy9tU/ruLUJ+/4fCijJ9VxD9/vsh79BzeXKoU04oiGRWKDOymePMuaq2yvT +j6X88iqTDj8rrhcZ8rSo0cmxNs9UNBzroSoi1SUMstqlJ6qKkEDUYHrnK7LmtSocOaa fvG6XbW0PvWlpC9D2bZ1gGZlDHfkCcUXpFx9MrC0WF3BiN/bLbeaqpELcjgGnkztKOSN Ip8zBFvSJqcikPi487jNbzuGfTSUOpConR/+k9b6GFAJlwuxdpgS4xzuIztmGa7QVaeR y7cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=BJd2E3GJT7zB/OoAoqW6c8vZf0/AtDkjskHmgpQhRc0=; b=iLmZASjKKZRqjA0Xyk/6gATzqChrhMvryRevNgxH586u4X59KuMJ7jB5Q0sXFzXrao bt/XkN4AI6Kj6RKysknehq1OF9vD+WncO8/V1D01QmrY7Dly5aEO6Lqu7qmFmldNQNBa voDN54ea5oM7cdHWU3ekAg01xSkGoMMFN7u8JTozxGAMq+npVpwg33MHMlO22x/vkVpH 3ZIP7ulRsby3Q72cYal3KLmJGKgFlDK3sKi4eqplt8aeH46lTZxLWDY5NNWQcnGmw22/ WGPn/Pstbddej5m5twU24Jkokvur0LeQ1DoqdNKyQBbTmsy/3rhBb+lPJi1VIWDjlIwZ jTCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=V9rb1hgt; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h62si8729124pgc.306.2018.01.09.00.33.11; Tue, 09 Jan 2018 00:33:11 -0800 (PST) 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=pass header.i=@nifty.com header.s=dec2015msa header.b=V9rb1hgt; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751636AbeAIIdI (ORCPT + 28 others); Tue, 9 Jan 2018 03:33:08 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:27298 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751145AbeAIIb7 (ORCPT ); Tue, 9 Jan 2018 03:31:59 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id w098Uugx024960; Tue, 9 Jan 2018 17:30:59 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com w098Uugx024960 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1515486660; bh=BJd2E3GJT7zB/OoAoqW6c8vZf0/AtDkjskHmgpQhRc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V9rb1hgtvLohIS0MgDv5vgBbvRdDGajMz3t20gc448w5RsIJ6BUEpz9xH4fojt1Rf GZVOaIvLI+zFe4aUuiE7l4oCXBBJYYceaywXbB5HPXybBhqeg+wWvDrLoSTk72xK6C TrEv3gLvQUL4zROygc2wMcYIS/4/wxA+8MaD2XEy027CujdkIAYHAslh11c+VbRQPp ae3WaVYWlGCO5rldPMfv0FI0V7Be/kPYwhqoa2ivGVU/MWSTGUQ6JKrKBrbOwB8zVU lw5YTbew3aOqka4lQkYvKJ5ABrQQtLIuX+7wtoAhqrILcB0xPvg8zpui5yTNtG6OLV l5MvIh1c8/vRQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Michal Marek , Lukas Bulwahn , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 6/6] fixdep: use existing helper to check modular CONFIG options Date: Tue, 9 Jan 2018 17:30:50 +0900 Message-Id: <1515486650-1141-6-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515486650-1141-1-git-send-email-yamada.masahiro@socionext.com> References: <1515486650-1141-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org str_ends_with() (it was strrcmp() before) was introduced to check if the given token ends with a particular string. Currently, it is used to check file paths without $(srctree). Actually, we have one more place where this helper is useful. Use it to check if CONFIG option ends with _MODULE. Signed-off-by: Masahiro Yamada --- scripts/basic/fixdep.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 3881bf1..9642302 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -230,6 +230,17 @@ static void use_config(const char *m, int slen) print_config(m, slen); } +/* test if s ends in sub */ +static int str_ends_with(const char *s, int slen, const char *sub) +{ + int sublen = strlen(sub); + + if (sublen > slen) + return 0; + + return !memcmp(s + slen - sublen, sub, sublen); +} + static void parse_config_file(const char *p) { const char *q, *r; @@ -239,7 +250,7 @@ static void parse_config_file(const char *p) q = p; while (*q && (isalnum(*q) || *q == '_')) q++; - if (memcmp(q - 7, "_MODULE", 7) == 0) + if (str_ends_with(p, q - p, "_MODULE")) r = q - 7; else r = q; @@ -249,17 +260,6 @@ static void parse_config_file(const char *p) } } -/* test if s ends in sub */ -static int str_ends_with(const char *s, int slen, const char *sub) -{ - int sublen = strlen(sub); - - if (sublen > slen) - return 0; - - return !memcmp(s + slen - sublen, sub, sublen); -} - static void *load_file(const char *filename) { struct stat st;