diff mbox series

[1/4] spapr: qemu_memalign() doesn't return NULL

Message ID 160371603337.305923.17158585537944509438.stgit@bahia.lan
State New
Headers show
Series spapr: Error handling fixes and cleanups (round 5) | expand

Commit Message

Greg Kurz Oct. 26, 2020, 12:40 p.m. UTC
qemu_memalign() aborts if OOM. Drop some dead code.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/ppc/spapr.c       |    6 ------
 hw/ppc/spapr_hcall.c |    8 ++------
 2 files changed, 2 insertions(+), 12 deletions(-)

Comments

Philippe Mathieu-Daudé Oct. 26, 2020, 1:43 p.m. UTC | #1
On 10/26/20 1:40 PM, Greg Kurz wrote:
> qemu_memalign() aborts if OOM. Drop some dead code.

> 

> Signed-off-by: Greg Kurz <groug@kaod.org>

> ---

>   hw/ppc/spapr.c       |    6 ------

>   hw/ppc/spapr_hcall.c |    8 ++------

>   2 files changed, 2 insertions(+), 12 deletions(-)

> 

> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c

> index 0cc19b5863a4..f098d0ee6d98 100644

> --- a/hw/ppc/spapr.c

> +++ b/hw/ppc/spapr.c

> @@ -1521,12 +1521,6 @@ void spapr_reallocate_hpt(SpaprMachineState *spapr, int shift,

>           int i;

>   

>           spapr->htab = qemu_memalign(size, size);

> -        if (!spapr->htab) {

> -            error_setg_errno(errp, errno,

> -                             "Could not allocate HPT of order %d", shift);

> -            return;


Wasn't the idea to use qemu_try_memalign() here?

> -        }

> -

>           memset(spapr->htab, 0, size);

>           spapr->htab_shift = shift;

>   

> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c

> index 607740150fa2..34e146f628fb 100644

> --- a/hw/ppc/spapr_hcall.c

> +++ b/hw/ppc/spapr_hcall.c

> @@ -361,12 +361,8 @@ static void *hpt_prepare_thread(void *opaque)

>       size_t size = 1ULL << pending->shift;

>   

>       pending->hpt = qemu_memalign(size, size);

> -    if (pending->hpt) {

> -        memset(pending->hpt, 0, size);

> -        pending->ret = H_SUCCESS;

> -    } else {

> -        pending->ret = H_NO_MEM;


Ditto.

> -    }

> +    memset(pending->hpt, 0, size);

> +    pending->ret = H_SUCCESS;

>   

>       qemu_mutex_lock_iothread();

>
diff mbox series

Patch

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0cc19b5863a4..f098d0ee6d98 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1521,12 +1521,6 @@  void spapr_reallocate_hpt(SpaprMachineState *spapr, int shift,
         int i;
 
         spapr->htab = qemu_memalign(size, size);
-        if (!spapr->htab) {
-            error_setg_errno(errp, errno,
-                             "Could not allocate HPT of order %d", shift);
-            return;
-        }
-
         memset(spapr->htab, 0, size);
         spapr->htab_shift = shift;
 
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 607740150fa2..34e146f628fb 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -361,12 +361,8 @@  static void *hpt_prepare_thread(void *opaque)
     size_t size = 1ULL << pending->shift;
 
     pending->hpt = qemu_memalign(size, size);
-    if (pending->hpt) {
-        memset(pending->hpt, 0, size);
-        pending->ret = H_SUCCESS;
-    } else {
-        pending->ret = H_NO_MEM;
-    }
+    memset(pending->hpt, 0, size);
+    pending->ret = H_SUCCESS;
 
     qemu_mutex_lock_iothread();