All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: qemu-devel@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>,
	qemu-trivial@nongnu.org, Michael Tokarev <mjt@tls.msk.ru>
Subject: [Qemu-devel] [PULL 06/16] sparc: Use g_memdup() instead of g_new0() + memcpy()
Date: Tue, 13 Sep 2016 19:04:45 +0300	[thread overview]
Message-ID: <a337f295defad7eb977da4d6317cf70f7f2fa4b4.1473782118.git.mjt@msgid.tls.msk.ru> (raw)
In-Reply-To: <cover.1473782118.git.mjt@tls.msk.ru>
In-Reply-To: <cover.1473782118.git.mjt@tls.msk.ru>

From: Thomas Huth <thuth@redhat.com>

There is no need to make sure that the memory is zeroed after the
allocation if we also immediatly fill the whole buffer afterwards
with memcpy(). Thus g_new0 should be g_new instead. But since we
are also doing a memcpy() here, we can also simply replace both
with g_memdup() instead.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Acked-By: Artyom Tarasenko <atar4qemu@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 target-sparc/cpu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/target-sparc/cpu.c b/target-sparc/cpu.c
index e4089f2..800a25a 100644
--- a/target-sparc/cpu.c
+++ b/target-sparc/cpu.c
@@ -117,8 +117,7 @@ static int cpu_sparc_register(SPARCCPU *cpu, const char *cpu_model)
         return -1;
     }
 
-    env->def = g_new0(sparc_def_t, 1);
-    memcpy(env->def, def, sizeof(*def));
+    env->def = g_memdup(def, sizeof(*def));
 
     featurestr = strtok(NULL, ",");
     sparc_cpu_parse_features(CPU(cpu), featurestr, &err);
-- 
2.1.4

  parent reply	other threads:[~2016-09-13 16:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1473782118.git.mjt@tls.msk.ru>
2016-09-13 16:04 ` [Qemu-devel] [PULL 01/16] docs: Fix description of the leaky bucket algorithm in throttle.txt Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 02/16] hw/bt/hci: spelling fix: endianness Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 03/16] hw/dma/omap: " Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 04/16] arm: spelling fix: mismatch Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 05/16] vl: remove unnecessary duplicate call to tpm_cleanup Michael Tokarev
2016-09-13 16:04 ` Michael Tokarev [this message]
2016-09-13 16:04 ` [Qemu-devel] [PULL 07/16] pic: fix typo in error message: KVM_GET_IRQCHIP -> KVM_SET_IRQCHIP Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 08/16] linux-user, trivial: display "0x%x" instead of "0x%d" Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 09/16] trace-event: display "%d" " Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 10/16] Document that curses usually needs -k option too Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 11/16] maint: Ignore generated version file Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 12/16] timer.h: fix typo Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 13/16] timer.h: fix inconsistency between comment and function prototype Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 14/16] timer/cpus: fix some typos and update some comments Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 15/16] target-m68k: fix get_mac_extf helper Michael Tokarev
2016-09-13 16:04 ` [Qemu-devel] [PULL 16/16] hw/net/e1000e: Fix compiler warning Michael Tokarev

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=a337f295defad7eb977da4d6317cf70f7f2fa4b4.1473782118.git.mjt@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.