From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: mprivozn@redhat.com
Subject: [PATCH] hostmem: simplify the code
Date: Thu, 6 Jun 2024 11:37:13 +0200 [thread overview]
Message-ID: <20240606093713.2469676-1-pbonzini@redhat.com> (raw)
No semantic change, just simpler control flow.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
backends/hostmem.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 37be93c8bb3..33baca6a974 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -178,12 +178,8 @@ static void host_memory_backend_set_merge(Object *obj, bool value, Error **errp)
return;
}
- if (!host_memory_backend_mr_inited(backend)) {
- backend->merge = value;
- return;
- }
-
- if (value != backend->merge) {
+ if (!host_memory_backend_mr_inited(backend) &&
+ value != backend->merge) {
void *ptr = memory_region_get_ram_ptr(&backend->mr);
uint64_t sz = memory_region_size(&backend->mr);
@@ -194,9 +190,9 @@ static void host_memory_backend_set_merge(Object *obj, bool value, Error **errp)
object_get_typename(obj));
return;
}
-
- backend->merge = value;
}
+
+ backend->merge = value;
}
static bool host_memory_backend_get_dump(Object *obj, Error **errp)
@@ -218,12 +214,8 @@ static void host_memory_backend_set_dump(Object *obj, bool value, Error **errp)
return;
}
- if (!host_memory_backend_mr_inited(backend)) {
- backend->dump = value;
- return;
- }
-
- if (value != backend->dump) {
+ if (host_memory_backend_mr_inited(backend) &&
+ value != backend->dump) {
void *ptr = memory_region_get_ram_ptr(&backend->mr);
uint64_t sz = memory_region_size(&backend->mr);
@@ -234,9 +226,9 @@ static void host_memory_backend_set_dump(Object *obj, bool value, Error **errp)
object_get_typename(obj));
return;
}
-
- backend->dump = value;
}
+
+ backend->dump = value;
}
static bool host_memory_backend_get_prealloc(Object *obj, Error **errp)
--
2.45.1
next reply other threads:[~2024-06-06 9:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-06 9:37 Paolo Bonzini [this message]
2024-06-06 10:09 ` [PATCH] hostmem: simplify the code Philippe Mathieu-Daudé
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=20240606093713.2469676-1-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=mprivozn@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).