From patchwork Thu Jan 21 03:51:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 571026 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E986C14010F for ; Thu, 21 Jan 2016 14:51:54 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id D38501A18B9 for ; Thu, 21 Jan 2016 14:51:54 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 60C7A1A1850 for ; Thu, 21 Jan 2016 14:51:41 +1100 (AEDT) Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 20 Jan 2016 20:51:39 -0700 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 20 Jan 2016 20:51:36 -0700 X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: stewart@linux.vnet.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 7EF383E40044 for ; Wed, 20 Jan 2016 20:38:29 -0700 (MST) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u0L3pabX27525266 for ; Wed, 20 Jan 2016 20:51:36 -0700 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u0L3pZm6015665 for ; Wed, 20 Jan 2016 20:51:36 -0700 Received: from birb.localdomain (birb.au.ibm.com [9.185.120.228] (may be forged)) by d03av04.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u0L3pQ6l015277; Wed, 20 Jan 2016 20:51:35 -0700 Received: from ka1.ozlabs.ibm.com (localhost.localdomain [127.0.0.1]) by birb.localdomain (Postfix) with ESMTP id C0FDD229EAAC; Thu, 21 Jan 2016 14:51:24 +1100 (AEDT) From: Stewart Smith To: skiboot@lists.ozlabs.org Date: Thu, 21 Jan 2016 14:51:10 +1100 Message-Id: <1453348281-16085-4-git-send-email-stewart@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453348281-16085-1-git-send-email-stewart@linux.vnet.ibm.com> References: <1453348281-16085-1-git-send-email-stewart@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16012103-8236-0000-0000-0000155FEA76 Subject: [Skiboot] [PATCH stable 03/14] Use VALGRIND callout rather than tricky malloc/memcpy X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" commit d04030556db4bb73151172ded3f279882e706dbd upstream The tricky memcpy trips up various static analysers and looks rather odd. The more correct thing to do is to ask valgrind to mark it as undefined. There's a call for that, and we depend on valgrind to run the test suite anyway, so we're not introducing a new dependency. Signed-off-by: Stewart Smith --- hdata/test/hdata_to_dt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hdata/test/hdata_to_dt.c b/hdata/test/hdata_to_dt.c index 9d23f3385624..9e5abf8f0070 100644 --- a/hdata/test/hdata_to_dt.c +++ b/hdata/test/hdata_to_dt.c @@ -25,6 +25,8 @@ #include +#include + struct dt_node *opal_node; /* Our actual map. */ @@ -138,9 +140,7 @@ static void dump_val(unsigned indent, const void *prop, size_t size) /* Make sure valgrind knows these are undefined bytes. */ static void undefined_bytes(void *p, size_t len) { - void *undef = malloc(len); - memcpy(p, undef, len); - free(undef); + VALGRIND_MAKE_MEM_UNDEFINED(p, len); } static void dump_dt(const struct dt_node *root, unsigned indent)