qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc()
@ 2015-02-04 10:26 Markus Armbruster
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 1/6] onenand: g_malloc() can't fail, bury dead error handling Markus Armbruster
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Markus Armbruster @ 2015-02-04 10:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, arei.gonglei, thuth

I'm routing these patches through qemu-trivial, even though some of
them touch actively maintained code, and could go through the
respective tree instead:

* PATCH 1 block (Kevin, Stefan)

* PATCH 3 KVM (Paolo)

* PATCH 4 migration (Juan, Amit)

* PATCH 5 VNC (Gerd)

If you want me to reroute any of them, let me know.

v2:
* Trivially rebased, R-bys retained

Markus Armbruster (6):
  onenand: g_malloc() can't fail, bury dead error handling
  rtl8139: g_malloc() can't fail, bury dead error handling
  kvm: g_malloc() can't fail, bury dead error handling
  rdma: g_malloc0() can't fail, bury dead error handling
  vnc: g_realloc() can't fail, bury dead error handling
  translate-all: Use g_try_malloc() for dynamic translator buffer

 hw/block/onenand.c |  8 +-------
 hw/net/rtl8139.c   | 14 --------------
 kvm-all.c          |  4 ----
 migration/rdma.c   |  3 ---
 translate-all.c    |  2 +-
 ui/vnc.c           |  4 ----
 6 files changed, 2 insertions(+), 33 deletions(-)

-- 
1.9.3

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v2 1/6] onenand: g_malloc() can't fail, bury dead error handling
  2015-02-04 10:26 [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc() Markus Armbruster
@ 2015-02-04 10:26 ` Markus Armbruster
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 2/6] rtl8139: " Markus Armbruster
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Markus Armbruster @ 2015-02-04 10:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, arei.gonglei, thuth

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/block/onenand.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/hw/block/onenand.c b/hw/block/onenand.c
index 348630d..1b2c893 100644
--- a/hw/block/onenand.c
+++ b/hw/block/onenand.c
@@ -346,15 +346,9 @@ static inline int onenand_prog_spare(OneNANDState *s, int sec, int secn,
 static inline int onenand_erase(OneNANDState *s, int sec, int num)
 {
     uint8_t *blankbuf, *tmpbuf;
+
     blankbuf = g_malloc(512);
-    if (!blankbuf) {
-        return 1;
-    }
     tmpbuf = g_malloc(512);
-    if (!tmpbuf) {
-        g_free(blankbuf);
-        return 1;
-    }
     memset(blankbuf, 0xff, 512);
     for (; num > 0; num--, sec++) {
         if (s->blk_cur) {
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v2 2/6] rtl8139: g_malloc() can't fail, bury dead error handling
  2015-02-04 10:26 [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc() Markus Armbruster
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 1/6] onenand: g_malloc() can't fail, bury dead error handling Markus Armbruster
@ 2015-02-04 10:26 ` Markus Armbruster
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 3/6] kvm: " Markus Armbruster
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Markus Armbruster @ 2015-02-04 10:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, arei.gonglei, thuth

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
---
 hw/net/rtl8139.c | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 6fa9e0a..b55e438 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -2075,20 +2075,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
                 "length to %d\n", txsize);
     }
 
-    if (!s->cplus_txbuffer)
-    {
-        /* out of memory */
-
-        DPRINTF("+++ C+ mode transmiter failed to reallocate %d bytes\n",
-            s->cplus_txbuffer_len);
-
-        /* update tally counter */
-        ++s->tally_counters.TxERR;
-        ++s->tally_counters.TxAbt;
-
-        return 0;
-    }
-
     /* append more data to the packet */
 
     DPRINTF("+++ C+ mode transmit reading %d bytes from host memory at "
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v2 3/6] kvm: g_malloc() can't fail, bury dead error handling
  2015-02-04 10:26 [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc() Markus Armbruster
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 1/6] onenand: g_malloc() can't fail, bury dead error handling Markus Armbruster
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 2/6] rtl8139: " Markus Armbruster
@ 2015-02-04 10:26 ` Markus Armbruster
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 4/6] rdma: g_malloc0() " Markus Armbruster
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Markus Armbruster @ 2015-02-04 10:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, arei.gonglei, thuth

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
---
 kvm-all.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 2f21a4e..05a79c2 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -2070,10 +2070,6 @@ int kvm_insert_breakpoint(CPUState *cpu, target_ulong addr,
         }
 
         bp = g_malloc(sizeof(struct kvm_sw_breakpoint));
-        if (!bp) {
-            return -ENOMEM;
-        }
-
         bp->pc = addr;
         bp->use_count = 1;
         err = kvm_arch_insert_sw_breakpoint(cpu, bp);
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v2 4/6] rdma: g_malloc0() can't fail, bury dead error handling
  2015-02-04 10:26 [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc() Markus Armbruster
                   ` (2 preceding siblings ...)
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 3/6] kvm: " Markus Armbruster
@ 2015-02-04 10:26 ` Markus Armbruster
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 5/6] vnc: g_realloc() " Markus Armbruster
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Markus Armbruster @ 2015-02-04 10:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, arei.gonglei, thuth

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
---
 migration/rdma.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/migration/rdma.c b/migration/rdma.c
index b32dbdf..306570d 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -1147,9 +1147,6 @@ static int qemu_rdma_register_and_get_keys(RDMAContext *rdma,
     /* allocate memory to store chunk MRs */
     if (!block->pmr) {
         block->pmr = g_malloc0(block->nb_chunks * sizeof(struct ibv_mr *));
-        if (!block->pmr) {
-            return -1;
-        }
     }
 
     /*
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v2 5/6] vnc: g_realloc() can't fail, bury dead error handling
  2015-02-04 10:26 [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc() Markus Armbruster
                   ` (3 preceding siblings ...)
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 4/6] rdma: g_malloc0() " Markus Armbruster
@ 2015-02-04 10:26 ` Markus Armbruster
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 6/6] translate-all: Use g_try_malloc() for dynamic translator buffer Markus Armbruster
  2015-02-08 10:51 ` [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc() Michael Tokarev
  6 siblings, 0 replies; 8+ messages in thread
From: Markus Armbruster @ 2015-02-04 10:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, arei.gonglei, thuth

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
---
 ui/vnc.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index a742c90..02552ee 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -659,10 +659,6 @@ void buffer_reserve(Buffer *buffer, size_t len)
     if ((buffer->capacity - buffer->offset) < len) {
         buffer->capacity += (len + 1024);
         buffer->buffer = g_realloc(buffer->buffer, buffer->capacity);
-        if (buffer->buffer == NULL) {
-            fprintf(stderr, "vnc: out of memory\n");
-            exit(1);
-        }
     }
 }
 
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH v2 6/6] translate-all: Use g_try_malloc() for dynamic translator buffer
  2015-02-04 10:26 [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc() Markus Armbruster
                   ` (4 preceding siblings ...)
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 5/6] vnc: g_realloc() " Markus Armbruster
@ 2015-02-04 10:26 ` Markus Armbruster
  2015-02-08 10:51 ` [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc() Michael Tokarev
  6 siblings, 0 replies; 8+ messages in thread
From: Markus Armbruster @ 2015-02-04 10:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, arei.gonglei, thuth

The USE_MMAP code can fail, and the caller handles the failure
already.  Let the !USE_MMAP code fail as well, for consistency.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Gonglei <arei.gonglei@huawei.com>
---
 translate-all.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/translate-all.c b/translate-all.c
index 4a1b64f..9f47ce7 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -631,7 +631,7 @@ static inline void *alloc_code_gen_buffer(void)
 #else
 static inline void *alloc_code_gen_buffer(void)
 {
-    void *buf = g_malloc(tcg_ctx.code_gen_buffer_size);
+    void *buf = g_try_malloc(tcg_ctx.code_gen_buffer_size);
 
     if (buf == NULL) {
         return NULL;
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc()
  2015-02-04 10:26 [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc() Markus Armbruster
                   ` (5 preceding siblings ...)
  2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 6/6] translate-all: Use g_try_malloc() for dynamic translator buffer Markus Armbruster
@ 2015-02-08 10:51 ` Michael Tokarev
  6 siblings, 0 replies; 8+ messages in thread
From: Michael Tokarev @ 2015-02-08 10:51 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: qemu-trivial, arei.gonglei, thuth

04.02.2015 13:26, Markus Armbruster wrote:
> I'm routing these patches through qemu-trivial, even though some of
> them touch actively maintained code, and could go through the
> respective tree instead:
> 
> * PATCH 1 block (Kevin, Stefan)
> 
> * PATCH 3 KVM (Paolo)
> 
> * PATCH 4 migration (Juan, Amit)
> 
> * PATCH 5 VNC (Gerd)
> 
> If you want me to reroute any of them, let me know.
> 
> v2:
> * Trivially rebased, R-bys retained
> 
> Markus Armbruster (6):
>   onenand: g_malloc() can't fail, bury dead error handling
>   rtl8139: g_malloc() can't fail, bury dead error handling
>   kvm: g_malloc() can't fail, bury dead error handling
>   rdma: g_malloc0() can't fail, bury dead error handling
>   vnc: g_realloc() can't fail, bury dead error handling
>   translate-all: Use g_try_malloc() for dynamic translator buffer

Applied all to -trivial, thank you!

/mjt

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-02-08 10:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-04 10:26 [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc() Markus Armbruster
2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 1/6] onenand: g_malloc() can't fail, bury dead error handling Markus Armbruster
2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 2/6] rtl8139: " Markus Armbruster
2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 3/6] kvm: " Markus Armbruster
2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 4/6] rdma: g_malloc0() " Markus Armbruster
2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 5/6] vnc: g_realloc() " Markus Armbruster
2015-02-04 10:26 ` [Qemu-devel] [PATCH v2 6/6] translate-all: Use g_try_malloc() for dynamic translator buffer Markus Armbruster
2015-02-08 10:51 ` [Qemu-devel] [PATCH v2 0/6] Trivial cleanups around g_malloc() Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).