Patchwork [01/27] buffered_file: g_realloc() can't fail

login
register
mail settings
Submitter Juan Quintela
Date July 24, 2012, 6:36 p.m.
Message ID <1343155012-26316-2-git-send-email-quintela@redhat.com>
Download mbox | patch
Permalink /patch/173004/
State New
Headers show

Comments

Juan Quintela - July 24, 2012, 6:36 p.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 buffered_file.c |   10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

Patch

diff --git a/buffered_file.c b/buffered_file.c
index f170aa0..4148abb 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -50,20 +50,12 @@  static void buffered_append(QEMUFileBuffered *s,
                             const uint8_t *buf, size_t size)
 {
     if (size > (s->buffer_capacity - s->buffer_size)) {
-        void *tmp;
-
         DPRINTF("increasing buffer capacity from %zu by %zu\n",
                 s->buffer_capacity, size + 1024);

         s->buffer_capacity += size + 1024;

-        tmp = g_realloc(s->buffer, s->buffer_capacity);
-        if (tmp == NULL) {
-            fprintf(stderr, "qemu file buffer expansion failed\n");
-            exit(1);
-        }
-
-        s->buffer = tmp;
+        s->buffer = g_realloc(s->buffer, s->buffer_capacity);
     }

     memcpy(s->buffer + s->buffer_size, buf, size);