[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/4] modules: factor out arch check
From: |
Gerd Hoffmann |
Subject: |
[PATCH 1/4] modules: factor out arch check |
Date: |
Thu, 10 Jun 2021 12:15:50 +0200 |
Move check to helper function for easy reuse.
No functional change.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
util/module.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/util/module.c b/util/module.c
index 4f98cc74ae37..860c257fc56e 100644
--- a/util/module.c
+++ b/util/module.c
@@ -129,6 +129,21 @@ void module_allow_arch(const char *arch)
module_arch = arch;
}
+static bool module_check_arch(ModuleInfo *info)
+{
+ if (info->has_arch) {
+ if (!module_arch) {
+ /* no arch set -> ignore all */
+ return false;
+ }
+ if (strcmp(module_arch, info->arch) != 0) {
+ /* mismatch */
+ return false;
+ }
+ }
+ return true;
+}
+
static void module_load_path_init(void)
{
const char *search_dir;
@@ -301,12 +316,9 @@ bool module_load_one(const char *prefix, const char
*lib_name, bool mayfail)
module_load_modinfo();
for (modlist = modinfo->list; modlist != NULL; modlist = modlist->next) {
- if (modlist->value->has_arch) {
- if (strcmp(modlist->value->name, module_name) == 0) {
- if (!module_arch ||
- strcmp(modlist->value->arch, module_arch) != 0) {
- return false;
- }
+ if (strcmp(modlist->value->name, module_name) == 0) {
+ if (!module_check_arch(modlist->value)) {
+ return false;
}
}
if (modlist->value->has_deps) {
--
2.31.1
- [PATCH 0/4] modules: add support for target-specific modules., Gerd Hoffmann, 2021/06/10
- [PATCH 1/4] modules: factor out arch check,
Gerd Hoffmann <=
- [PATCH 2/4] modules: check arch on qom lookup, Gerd Hoffmann, 2021/06/10
- [PATCH 3/4] modules: target-specific module build infrastructure, Gerd Hoffmann, 2021/06/10
- [PATCH 4/4] modules: build virtio-9p modular, Gerd Hoffmann, 2021/06/10
- Re: [PATCH 0/4] modules: add support for target-specific modules., Claudio Fontana, 2021/06/10
- Re: [PATCH 0/4] modules: add support for target-specific modules., Gerd Hoffmann, 2021/06/10
- Re: [PATCH 0/4] modules: add support for target-specific modules., Gerd Hoffmann, 2021/06/10
- Re: [PATCH 0/4] modules: add support for target-specific modules., Claudio Fontana, 2021/06/10
- Re: [PATCH 0/4] modules: add support for target-specific modules., Paolo Bonzini, 2021/06/11
- Re: [PATCH 0/4] modules: add support for target-specific modules., Gerd Hoffmann, 2021/06/11
- Re: [PATCH 0/4] modules: add support for target-specific modules., Gerd Hoffmann, 2021/06/11