qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	Christian Schoenebeck <qemu_oss@crudebyte.com>,
	Greg Kurz <groug@kaod.org>,
	cfontana@suse.de, jose.ziviani@suse.com, pbonzini@redhat.com,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH 1/4] modules: factor out arch check
Date: Thu, 10 Jun 2021 12:15:50 +0200	[thread overview]
Message-ID: <20210610101553.943689-2-kraxel@redhat.com> (raw)
In-Reply-To: <20210610101553.943689-1-kraxel@redhat.com>

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



  reply	other threads:[~2021-06-10 10:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10 10:15 [PATCH 0/4] modules: add support for target-specific modules Gerd Hoffmann
2021-06-10 10:15 ` Gerd Hoffmann [this message]
2021-06-10 10:15 ` [PATCH 2/4] modules: check arch on qom lookup Gerd Hoffmann
2021-06-10 10:15 ` [PATCH 3/4] modules: target-specific module build infrastructure Gerd Hoffmann
2021-06-10 10:15 ` [PATCH 4/4] modules: build virtio-9p modular Gerd Hoffmann
2021-06-10 10:34 ` [PATCH 0/4] modules: add support for target-specific modules Claudio Fontana
2021-06-10 12:23   ` Gerd Hoffmann
2021-06-10 13:10     ` Gerd Hoffmann
2021-06-10 13:12     ` Claudio Fontana
2021-06-11  7:35       ` Paolo Bonzini
2021-06-11  8:29         ` Gerd Hoffmann
2021-06-11 13:03           ` Gerd Hoffmann
2021-06-11 13:17             ` Claudio Fontana
2021-06-14 22:19             ` José Ricardo Ziviani
2021-06-15  5:09               ` Gerd Hoffmann
2021-06-15 15:48                 ` José Ricardo Ziviani
2021-06-16  9:28                   ` Gerd Hoffmann
2021-06-16 12:23                     ` Claudio Fontana
2021-06-17  5:37                       ` Gerd Hoffmann
2021-06-17  7:48                         ` Claudio Fontana
2021-06-17  9:48                           ` Gerd Hoffmann
2021-06-17 10:07                             ` Claudio Fontana
2021-06-11 17:14           ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210610101553.943689-2-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=cfontana@suse.de \
    --cc=groug@kaod.org \
    --cc=jose.ziviani@suse.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).