From patchwork Thu Jan 11 13:05:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 124192 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp652834qgn; Thu, 11 Jan 2018 05:06:33 -0800 (PST) X-Google-Smtp-Source: ACJfBotZjSra5lNjYAsX/7uBRdCQC8iOdwT8ED6mtWkpaf5cX3HtdQu3730deD/GsjwYebWSEKNI X-Received: by 10.99.44.14 with SMTP id s14mr17746564pgs.452.1515675993033; Thu, 11 Jan 2018 05:06:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515675993; cv=none; d=google.com; s=arc-20160816; b=h8PLuvaB2mYSlR7yeBy1z6C3UzcCPQ0hxdxbJ77OmL5PmqKkBfUQakjGbIfSLWSmUA 7bcb+o8Z6wQhD4BcnIwpK9/KN1ThVgybHEjQdG9ZhvbrQs/ZdgVmZxvbhII5WUEfJAXe qHiEyFvWP4wilbV6FJghLF8/mSVQw/vrRk3aFnwnpfzVdMMIax+jyKEFSVQ5xY+x5A9P jPQZPh9LLEm7IRyqN0oBK4B2Hg7J9oWYtOk+0RQZYs3I21jMGzlPt97q1bXwlaQHHPbn i1QU2xbZoqc6NGUUymXweSAbF6+4mbWUL8554CQPukKYQ4LPBbhc9to33GP5YIvEOkpf KOEg== 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=ksfIr6M+6kyG4ooySJ9AwLYrTsN6Ic3kKlHcNhVbv4M=; b=zD5yybzwYNZyG/1QaCh9pNTefcAUhPdt80H4XeCvqDLr4THLw6uzaSeVjf/MOvJjOL b6hBYjoWnqk5mViS9L/f/793XfjVIubRquNo4bDTV+ubZWcHCodmJvrbFHJn0bjkYwC2 4ELaq/AHO0towuU0eHtD/vveSxHhMoEvvWUUgBuy/rX4RxIQYOPhRNPc8DWv+egNntKg qjAvoB1J6oNCuLy8P2zx9+xHCB0m0ghgVo/1IAkHcHr/JrjsQRGeFPTPeg//wQwdQaSq agTXAoP6c2yEnM2JQCrBa701CdXwrRguIXlXdLXEOX83p1pfbz9OSxYzBsS9s6N1xkS4 BZXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=gr+D01CT; 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 z21si4293066pge.348.2018.01.11.05.06.32; Thu, 11 Jan 2018 05:06:33 -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=gr+D01CT; 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 S934393AbeAKNG3 (ORCPT + 28 others); Thu, 11 Jan 2018 08:06:29 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:60577 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932665AbeAKNG1 (ORCPT ); Thu, 11 Jan 2018 08:06:27 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-12.nifty.com with ESMTP id w0BD5mX7031475; Thu, 11 Jan 2018 22:05:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com w0BD5mX7031475 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1515675952; bh=ksfIr6M+6kyG4ooySJ9AwLYrTsN6Ic3kKlHcNhVbv4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gr+D01CTfeWexAAV160lPXCXGEqvfFvDfV5Wwodanx8y9892Tyk1Cw7UU4vcvxW76 jgb0j4iOv+BwRYjn9FkNrTdd+BJPwLoLoCDF13t+F5+zArM+uj+U9oOZCdSLjCPZDe OSbBFSc9JdslzfB0E6shho5DLe86/Z7DA5KFcUr0/h4T0glqSDSzx9+jYCzssgVx0C VsFMPaPu0ULsq+pS6QxstbqvJrDjc6HcxImGiFLl0vhx0xNEDJSCYid3Ara1LJEQ6J Mm5Pk3mfj8LPSQSYgZNJOyG9kHWTjDA6yAu9vFD199jyfOl+qqtXhTXSVQFr4jnQ+T 036s0sIPCXA1w== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Michal Marek , Sam Ravnborg , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 7/7] fixdep: use existing helper to check modular CONFIG options Date: Thu, 11 Jan 2018 22:05:46 +0900 Message-Id: <1515675946-7514-7-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515675946-7514-1-git-send-email-yamada.masahiro@socionext.com> References: <1515675946-7514-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() tests 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 --- Changes in v2: None 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 0abc15778..fa3d39b6 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -219,6 +219,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; @@ -228,7 +239,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; @@ -238,17 +249,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 *read_file(const char *filename) { struct stat st;