From f937ddc901c78571016f054ebc456e9716fbde73 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 4 Nov 2004 12:10:24 +0000 Subject: cleanup code using kernel_module_extension() --- mdk-stage1/modules.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'mdk-stage1') diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c index 27edb0349..a0876416e 100644 --- a/mdk-stage1/modules.c +++ b/mdk-stage1/modules.c @@ -164,6 +164,11 @@ int insmod_local_file(char * path, char * options) } } +static char *kernel_module_extension(void) +{ + return kernel_version() <= 4 ? ".o" : ".ko"; +} + /* unarchive and insmod given module * WARNING: module must not contain the trailing ".o" */ @@ -174,10 +179,7 @@ static enum insmod_return insmod_archived_file(const char * mod_name, char * opt int i, rc; strncpy(module_name, mod_name, sizeof(module_name)); - if (kernel_version() <= 4) - strcat(module_name, ".o"); - else - strcat(module_name, ".ko"); + strcat(module_name, kernel_module_extension()); i = mar_extract_file(archive_name, module_name, "/tmp/"); if (i == 1) { static int recurse = 0; @@ -526,10 +528,7 @@ enum return_type ask_insmod(enum driver_type type) } if (results == RETURN_OK) { - if (kernel_version() <= 4) - choice[strlen(choice)-2] = '\0'; /* remove trailing .o */ - else - choice[strlen(choice)-3] = '\0'; /* remove trailing .ko */ + choice[strlen(choice)-strlen(kernel_module_extension())] = '\0'; /* remove trailing .ko or .o */ return insmod_with_options(choice, type); } else return results; -- cgit v1.2.1