qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] Error check find_ram_offset


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH] Error check find_ram_offset
Date: Tue, 01 Nov 2011 11:20:30 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Lightning/1.0b2 Thunderbird/3.1.13

On 10/31/2011 09:54 AM, Alex Williamson wrote:
Spotted via code review, we initialize offset to 0 to avoid a
compiler warning, but in the unlikely case that offset is
never set to something else, we should abort instead of return
a value that will almost certainly cause problems.

Signed-off-by: Alex Williamson<address@hidden>

Applied.  Thanks.

Regards,

Anthony Liguori

---

  exec.c |   11 +++++++++--
  1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/exec.c b/exec.c
index 9dc4edb..70f6fb8 100644
--- a/exec.c
+++ b/exec.c
@@ -2874,7 +2874,7 @@ static void *file_ram_alloc(RAMBlock *block,
  static ram_addr_t find_ram_offset(ram_addr_t size)
  {
      RAMBlock *block, *next_block;
-    ram_addr_t offset = 0, mingap = RAM_ADDR_MAX;
+    ram_addr_t offset = RAM_ADDR_MAX, mingap = RAM_ADDR_MAX;

      if (QLIST_EMPTY(&ram_list.blocks))
          return 0;
@@ -2890,10 +2890,17 @@ static ram_addr_t find_ram_offset(ram_addr_t size)
              }
          }
          if (next - end>= size&&  next - end<  mingap) {
-            offset =  end;
+            offset = end;
              mingap = next - end;
          }
      }
+
+    if (offset == RAM_ADDR_MAX) {
+        fprintf(stderr, "Failed to find gap of requested size: %" PRIu64 "\n",
+                (uint64_t)size);
+        abort();
+    }
+
      return offset;
  }








reply via email to

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