From patchwork Thu Jun 16 17:33:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 9181479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 50D9D60760 for ; Thu, 16 Jun 2016 18:00:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4969A280DE for ; Thu, 16 Jun 2016 18:00:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E1D42837A; Thu, 16 Jun 2016 18:00:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F149E280DE for ; Thu, 16 Jun 2016 18:00:36 +0000 (UTC) Received: from localhost ([::1]:51390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDbal-0001FA-SM for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Jun 2016 14:00:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDbAn-0006T5-BO for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:33:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDbAl-0003Dv-Dq for qemu-devel@nongnu.org; Thu, 16 Jun 2016 13:33:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38373) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDbAl-0003Dn-8r; Thu, 16 Jun 2016 13:33:43 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C04FCF604; Thu, 16 Jun 2016 17:33:41 +0000 (UTC) Received: from thh440s.fritz.box (vpn1-7-37.ams2.redhat.com [10.36.7.37]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5GHXcGu010692; Thu, 16 Jun 2016 13:33:39 -0400 From: Thomas Huth To: qemu-devel@nongnu.org, Mark Cave-Ayland Date: Thu, 16 Jun 2016 19:33:38 +0200 Message-Id: <1466098418-26899-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 16 Jun 2016 17:33:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] sparc: Use g_memdup() instead of g_new0() + memcpy() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Blue Swirl , qemu-trivial@nongnu.org, Artyom Tarasenko Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-By: Artyom Tarasenko --- 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 5b74cfc..7b43192 100644 --- a/target-sparc/cpu.c +++ b/target-sparc/cpu.c @@ -115,8 +115,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, ","); cc->parse_features(CPU(cpu), featurestr, &err);