diff mbox series

[PATCH-for-9.0,17/25] backends: Reduce variable scope in host_memory_backend_memory_complete

Message ID 20231120213301.24349-18-philmd@linaro.org
State Superseded
Headers show
Series memory: Propagate Error* when possible | expand

Commit Message

Philippe Mathieu-Daudé Nov. 20, 2023, 9:32 p.m. UTC
Reduce the &local_err variable use and remove the 'out:' label.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 backends/hostmem.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Manos Pitsidianakis Nov. 22, 2023, 7:32 a.m. UTC | #1
On Mon, 20 Nov 2023 23:32, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>Reduce the &local_err variable use and remove the 'out:' label.
>
>Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>---
> backends/hostmem.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
>diff --git a/backends/hostmem.c b/backends/hostmem.c
>index 3f8eb936d7..1b0043a0d9 100644
>--- a/backends/hostmem.c
>+++ b/backends/hostmem.c
>@@ -324,7 +324,6 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
> {
>     HostMemoryBackend *backend = MEMORY_BACKEND(uc);
>     HostMemoryBackendClass *bc = MEMORY_BACKEND_GET_CLASS(uc);
>-    Error *local_err = NULL;
>     void *ptr;
>     uint64_t sz;
> 
>@@ -400,15 +399,16 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
>      * specified NUMA policy in place.
>      */
>     if (backend->prealloc) {
>+        Error *local_err = NULL;
>+
>         qemu_prealloc_mem(memory_region_get_fd(&backend->mr), ptr, sz,
>                           backend->prealloc_threads,
>                           backend->prealloc_context, &local_err);
>         if (local_err) {
>-            goto out;
>+            error_propagate(errp, local_err);
>+            return;
>         }
>     }
>-out:
>-    error_propagate(errp, local_err);
> }
> 
> static bool
>-- 

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Gavin Shan Dec. 4, 2023, 4:58 a.m. UTC | #2
On 11/21/23 07:32, Philippe Mathieu-Daudé wrote:
> Reduce the &local_err variable use and remove the 'out:' label.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   backends/hostmem.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 

Reviewed-by: Gavin Shan <gshan@redhat.com>
diff mbox series

Patch

diff --git a/backends/hostmem.c b/backends/hostmem.c
index 3f8eb936d7..1b0043a0d9 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -324,7 +324,6 @@  host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
 {
     HostMemoryBackend *backend = MEMORY_BACKEND(uc);
     HostMemoryBackendClass *bc = MEMORY_BACKEND_GET_CLASS(uc);
-    Error *local_err = NULL;
     void *ptr;
     uint64_t sz;
 
@@ -400,15 +399,16 @@  host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
      * specified NUMA policy in place.
      */
     if (backend->prealloc) {
+        Error *local_err = NULL;
+
         qemu_prealloc_mem(memory_region_get_fd(&backend->mr), ptr, sz,
                           backend->prealloc_threads,
                           backend->prealloc_context, &local_err);
         if (local_err) {
-            goto out;
+            error_propagate(errp, local_err);
+            return;
         }
     }
-out:
-    error_propagate(errp, local_err);
 }
 
 static bool