qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC PATCH v1 08/25] memory: nop APIs when they have NULL a


From: Peter Crosthwaite
Subject: [Qemu-devel] [RFC PATCH v1 08/25] memory: nop APIs when they have NULL arguments
Date: Thu, 10 Sep 2015 22:33:18 -0700

When doing a subregion or alias and the SR/Aliased region is NULL,
perform no action. This makes the memory API tolerant of API calls
following an earlier failure with setting up these dependencies.
This in turn allows removal of some of the constant error-checking
boiler-plate from machine models.

Cc: Paolo Bonzini <address@hidden>
Signed-off-by: Peter Crosthwaite <address@hidden>
---

 memory.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/memory.c b/memory.c
index 0d8b2d9..2d03cb7 100644
--- a/memory.c
+++ b/memory.c
@@ -1266,6 +1266,9 @@ void memory_region_init_alias(MemoryRegion *mr,
                               hwaddr offset,
                               uint64_t size)
 {
+    if (!orig) {
+        return;
+    }
     memory_region_init(mr, owner, name, size);
     mr->alias = orig;
     mr->alias_offset = offset;
@@ -1759,6 +1762,9 @@ void memory_region_add_subregion(MemoryRegion *mr,
                                  hwaddr offset,
                                  MemoryRegion *subregion)
 {
+    if (!subregion) {
+        return;
+    }
     subregion->may_overlap = false;
     subregion->priority = 0;
     memory_region_add_subregion_common(mr, offset, subregion);
@@ -1769,6 +1775,9 @@ void memory_region_add_subregion_overlap(MemoryRegion *mr,
                                          MemoryRegion *subregion,
                                          int priority)
 {
+    if (!subregion) {
+        return;
+    }
     subregion->may_overlap = true;
     subregion->priority = priority;
     memory_region_add_subregion_common(mr, offset, subregion);
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]