[RFC,2/3] depmod: search key: move builtin detection under the add function
diff mbox

Message ID 20161123152339.27531-3-yauheni.kaliuta@redhat.com
State Accepted
Headers show

Commit Message

Yauheni Kaliuta Nov. 23, 2016, 3:23 p.m. UTC
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 <yauheni.kaliuta@redhat.com>
---
 tools/depmod.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Lucas De Marchi May 9, 2017, 7:04 a.m. UTC | #1
On Wed, Nov 23, 2016 at 7:23 AM, Yauheni Kaliuta
<yauheni.kaliuta@redhat.com> wrote:
> 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 <yauheni.kaliuta@redhat.com>
> ---


Applied, thanks.


Lucas De Marchi
--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

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;
 }