diff mbox series

[2/3] sysemu/xen: Remove unreachable xen_ram_alloc() code

Message ID 20230905122142.5939-3-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series sysemu/accel: Simplify sysemu/xen.h | expand

Commit Message

Philippe Mathieu-Daudé Sept. 5, 2023, 12:21 p.m. UTC
The xen_ram_alloc() call in softmmu/physmem.c is guarded
by checking for xen_enabled(), which evaluate to 'false'
when XEN is not built in. The compiler elide the function
call, and thus the inlined function is not used. Remove it.

Inspired-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/sysemu/xen.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Comments

Michael Tokarev Oct. 4, 2023, 12:16 p.m. UTC | #1
05.09.2023 15:21, Philippe Mathieu-Daudé wrote:
> The xen_ram_alloc() call in softmmu/physmem.c is guarded
> by checking for xen_enabled(), which evaluate to 'false'
> when XEN is not built in. The compiler elide the function
> call, and thus the inlined function is not used. Remove it.

I still don't think it is a good way to just eliminate the
function (stub) in a hope compiler will elide the call.  It's
definitely not guaranteed by any standard, and compiler itself
can produce varying results (eg building with -O0 to make gdb
debugging easier).

static inline function costs nothing but keeps whole thing
manageable. IMHO anyway.

/mjt

> Inspired-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/sysemu/xen.h | 10 +++-------
>   1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/include/sysemu/xen.h b/include/sysemu/xen.h
> index 9b2d0b21ff..1f797a9abe 100644
> --- a/include/sysemu/xen.h
> +++ b/include/sysemu/xen.h
> @@ -27,8 +27,6 @@ extern bool xen_allowed;
>   #define xen_enabled()           (xen_allowed)
>   
>   void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length);
> -void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
> -                   struct MemoryRegion *mr, Error **errp);
>   
>   #else /* !CONFIG_XEN_IS_POSSIBLE */
>   
> @@ -38,12 +36,10 @@ static inline void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
>   {
>       /* nothing */
>   }
> -static inline void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
> -                                 MemoryRegion *mr, Error **errp)
> -{
> -    g_assert_not_reached();
> -}
>   
>   #endif /* CONFIG_XEN_IS_POSSIBLE */
>   
> +void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
> +                   struct MemoryRegion *mr, Error **errp);
> +
>   #endif
diff mbox series

Patch

diff --git a/include/sysemu/xen.h b/include/sysemu/xen.h
index 9b2d0b21ff..1f797a9abe 100644
--- a/include/sysemu/xen.h
+++ b/include/sysemu/xen.h
@@ -27,8 +27,6 @@  extern bool xen_allowed;
 #define xen_enabled()           (xen_allowed)
 
 void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length);
-void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
-                   struct MemoryRegion *mr, Error **errp);
 
 #else /* !CONFIG_XEN_IS_POSSIBLE */
 
@@ -38,12 +36,10 @@  static inline void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length)
 {
     /* nothing */
 }
-static inline void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
-                                 MemoryRegion *mr, Error **errp)
-{
-    g_assert_not_reached();
-}
 
 #endif /* CONFIG_XEN_IS_POSSIBLE */
 
+void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
+                   struct MemoryRegion *mr, Error **errp);
+
 #endif