qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Riku Voipio <riku.voipio@iki.fi>
Subject: [Qemu-devel] [PATCH 5/5] linux-user/syscall: Replace g_malloc0 + memcpy with g_memdup
Date: Thu,  8 Oct 2015 21:35:16 +0200	[thread overview]
Message-ID: <1444332916-16476-6-git-send-email-thuth@redhat.com> (raw)
In-Reply-To: <1444332916-16476-1-git-send-email-thuth@redhat.com>

No need to use g_malloc0 to zero the memory if we memcpy to
the whole buffer afterwards anyway. Actually, there is even
a function which combines both steps, g_memdup, so let's use
this function here instead.

Cc: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 linux-user/syscall.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 98b5766..f2ada0a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5325,8 +5325,7 @@ static abi_long do_open_by_handle_at(abi_long mount_fd, abi_long handle,
         return -TARGET_EFAULT;
     }
 
-    fh = g_malloc0(total_size);
-    memcpy(fh, target_fh, total_size);
+    fh = g_memdup(target_fh, total_size);
     fh->handle_bytes = size;
     fh->handle_type = tswap32(target_fh->handle_type);
 
-- 
1.8.3.1

  parent reply	other threads:[~2015-10-08 19:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-08 19:35 [Qemu-devel] [PATCH 0/5] Small optimizations for code using g_malloc0 + memset/memcpy Thomas Huth
2015-10-08 19:35 ` [Qemu-devel] [PATCH 1/5] hw/dma/pxa2xx: Remove superfluous memset Thomas Huth
2015-10-08 20:59   ` Eric Blake
2015-10-09  6:39     ` Thomas Huth
2015-10-08 19:35 ` [Qemu-devel] [PATCH 2/5] hw/scsi/spapr_vscsi: " Thomas Huth
2015-10-08 21:00   ` Eric Blake
2015-10-09  1:51   ` David Gibson
2015-10-08 19:35 ` [Qemu-devel] [PATCH 3/5] hw/input/tsc210x: " Thomas Huth
2015-10-08 23:34   ` Eric Blake
2015-10-09  6:40     ` Thomas Huth
2015-10-08 19:35 ` [Qemu-devel] [PATCH 4/5] tests/i44fx-test: No need for zeroing memory before memset Thomas Huth
2015-10-08 20:24   ` Laszlo Ersek
2015-10-09  6:36     ` Thomas Huth
2015-10-09  6:46     ` Markus Armbruster
2015-10-09  8:08       ` Laszlo Ersek
2015-10-08 19:35 ` Thomas Huth [this message]
2015-10-08 23:32   ` [Qemu-devel] [PATCH 5/5] linux-user/syscall: Replace g_malloc0 + memcpy with g_memdup Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444332916-16476-6-git-send-email-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).