memory: Have memory_region_init_ram_from_file() handler return a boolean
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Mon, 20 Nov 2023 12:45:13 +0000 (13:45 +0100)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Fri, 5 Jan 2024 15:20:15 +0000 (16:20 +0100)
Following the example documented since commit e3fe3988d7 ("error:
Document Error API usage rules"), have memory_region_init_ram_from_file
return a boolean indicating whether an error is set or not.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Message-Id: <20231120213301.24349-13-philmd@linaro.org>

include/exec/memory.h
system/memory.c

index faddf8f0732733ea93824914a392e4bc6d3ba9f1..c39819ec759a069a7849fe7e0c5bfed6e2019b7e 100644 (file)
@@ -1376,8 +1376,10 @@ bool memory_region_init_resizeable_ram(MemoryRegion *mr,
  *
  * Note that this function does not do anything to cause the data in the
  * RAM memory region to be migrated; that is the responsibility of the caller.
+ *
+ * Return: true on success, else false setting @errp with error.
  */
-void memory_region_init_ram_from_file(MemoryRegion *mr,
+bool memory_region_init_ram_from_file(MemoryRegion *mr,
                                       Object *owner,
                                       const char *name,
                                       uint64_t size,
index 75303484e17215bef1b9d65a94e48d54b3faec89..e05d88aa67112b60b81ceb272c01a8a743f0cea2 100644 (file)
@@ -1605,7 +1605,7 @@ bool memory_region_init_resizeable_ram(MemoryRegion *mr,
 }
 
 #ifdef CONFIG_POSIX
-void memory_region_init_ram_from_file(MemoryRegion *mr,
+bool memory_region_init_ram_from_file(MemoryRegion *mr,
                                       Object *owner,
                                       const char *name,
                                       uint64_t size,
@@ -1628,7 +1628,9 @@ void memory_region_init_ram_from_file(MemoryRegion *mr,
         mr->size = int128_zero();
         object_unparent(OBJECT(mr));
         error_propagate(errp, err);
+        return false;
     }
+    return true;
 }
 
 void memory_region_init_ram_from_fd(MemoryRegion *mr,