From patchwork Wed Nov 23 15:23:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yauheni Kaliuta X-Patchwork-Id: 9443609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 59AD1600BA for ; Wed, 23 Nov 2016 15:22:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D83126D19 for ; Wed, 23 Nov 2016 15:22:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42438271CB; Wed, 23 Nov 2016 15:22:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7AE526D19 for ; Wed, 23 Nov 2016 15:22:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938712AbcKWPWq (ORCPT ); Wed, 23 Nov 2016 10:22:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60460 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935350AbcKWPWq (ORCPT ); Wed, 23 Nov 2016 10:22:46 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B16D064DB0; Wed, 23 Nov 2016 15:22:45 +0000 (UTC) Received: from astarta.redhat.com (vpn1-6-30.ams2.redhat.com [10.36.6.30]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uANFMevM023117 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 23 Nov 2016 10:22:44 -0500 From: Yauheni Kaliuta To: linux-modules@vger.kernel.org Cc: aris@redhat.com, Lucas De Marchi , yauheni.kaliuta@redhat.com Subject: [PATCH RFC 2/3] depmod: search key: move builtin detection under the add function Date: Wed, 23 Nov 2016 17:23:38 +0200 Message-Id: <20161123152339.27531-3-yauheni.kaliuta@redhat.com> In-Reply-To: <20161123152339.27531-1-yauheni.kaliuta@redhat.com> References: <20161123152339.27531-1-yauheni.kaliuta@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 23 Nov 2016 15:22:45 +0000 (UTC) Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Prepare to implement external directories support. It's better to isolated behaviour difference under the cfg_search_add() call, then make the client code aware of it. In case of external modules/directories support, there will be one more keyword added, so making the clients aware of it makes even less sense. Signed-off-by: Yauheni Kaliuta --- tools/depmod.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/depmod.c b/tools/depmod.c index a96501d1cbfb..81360a651811 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -452,10 +452,11 @@ struct cfg { struct cfg_search *searches; }; -static int cfg_search_add(struct cfg *cfg, const char *path, uint8_t builtin) +static int cfg_search_add(struct cfg *cfg, const char *path) { struct cfg_search *s; size_t len; + uint8_t builtin = streq(path, CFG_BUILTIN_KEY); if (builtin) len = 0; @@ -568,8 +569,7 @@ static int cfg_file_parse(struct cfg *cfg, const char *filename) if (streq(cmd, "search")) { const char *sp; while ((sp = strtok_r(NULL, "\t ", &saveptr)) != NULL) { - uint8_t builtin = streq(sp, CFG_BUILTIN_KEY); - cfg_search_add(cfg, sp, builtin); + cfg_search_add(cfg, sp); } } else if (streq(cmd, "override")) { const char *modname = strtok_r(NULL, "\t ", &saveptr); @@ -763,7 +763,7 @@ static int cfg_load(struct cfg *cfg, const char * const *cfg_paths) * list here. But only if there was no "search" option specified. */ if (cfg->searches == NULL) - cfg_search_add(cfg, "updates", 0); + cfg_search_add(cfg, "updates"); return 0; }