From patchwork Fri Aug 10 03:54:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peter A. G. Crosthwaite" X-Patchwork-Id: 176358 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6E2B02C0099 for ; Fri, 10 Aug 2012 13:55:58 +1000 (EST) Received: from localhost ([::1]:35316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzgKK-0002EO-IX for incoming@patchwork.ozlabs.org; Thu, 09 Aug 2012 23:55:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzgK7-0001zC-P6 for qemu-devel@nongnu.org; Thu, 09 Aug 2012 23:55:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzgK5-0001oz-PV for qemu-devel@nongnu.org; Thu, 09 Aug 2012 23:55:43 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:55892) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzgK5-0001o8-EB for qemu-devel@nongnu.org; Thu, 09 Aug 2012 23:55:41 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp12so1872821pbb.4 for ; Thu, 09 Aug 2012 20:55:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=eTstQQLzAE8okP/Jf3hfR/UxtHG6IPa8zaH0Icf7jUY=; b=ifJlf6iw3KA2VJLrp7OaLLUi1rQmmNmKEBiO8Sc506iw/prB7F2fve7E9duC4N1l1I N+DJmphqN+8B60GPZCuORHnqDOE7Tg0l0jB7IhCr7rk4I1VJ7aJY/12QTSPrVBuACUFj H0H9AjV5+tXhKPC5qiFmVRMrulEB5ROSDYkzJ7xz/N2SsZonpTySZgHaKACxTe0+gwPH UC/j6p/NZ6V5vNrU1E+754B5Iow5ykqUWlcOMIFB4ph6/aIs0Qq6xpe1cXJZZ2GZCwLN V8TsabXtB9/if1SeCrqj16kkP2Pscc3U2GaanEkAS4+KJgs95jrwU004nKlQuL6t1jGy KhYA== Received: by 10.68.129.168 with SMTP id nx8mr9019095pbb.112.1344570940867; Thu, 09 Aug 2012 20:55:40 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id ng8sm2451413pbc.13.2012.08.09.20.55.38 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Aug 2012 20:55:40 -0700 (PDT) From: "Peter A. G. Crosthwaite" To: peter.crosthwaite@petalogix.com, qemu-trivial@nongnu.org, agraf@suse.de, qemu-devel@nongnu.org Date: Fri, 10 Aug 2012 13:54:26 +1000 Message-Id: <1344570866-28595-2-git-send-email-peter.crosthwaite@petalogix.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1344570866-28595-1-git-send-email-peter.crosthwaite@petalogix.com> References: <1344570866-28595-1-git-send-email-peter.crosthwaite@petalogix.com> X-Gm-Message-State: ALoCoQmfvHupRXD2HbPRpCbqFWJc+m5xdd7JX0Di/jX/sMocShOJa/UsjMBLbqaXm1MRJsSD5+9Y X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Subject: [Qemu-devel] [PATCH] device_tree: load_device_tree(): Allow NULL sizep X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The sizep arg is populated with the size of the loaded device tree. Since this is one of those informational "please populate" type arguments it should be optional. Guarded writes to *sizep against NULL accordingly. Signed-off-by: Peter A. G. Crosthwaite Acked-by: Alexander Graf --- device_tree.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/device_tree.c b/device_tree.c index d7a9b6b..641a48a 100644 --- a/device_tree.c +++ b/device_tree.c @@ -71,7 +71,9 @@ void *load_device_tree(const char *filename_path, int *sizep) int ret; void *fdt = NULL; - *sizep = 0; + if (sizep) { + *sizep = 0; + } dt_size = get_image_size(filename_path); if (dt_size < 0) { printf("Unable to get size of device tree file '%s'\n", @@ -104,7 +106,9 @@ void *load_device_tree(const char *filename_path, int *sizep) filename_path); goto fail; } - *sizep = dt_size; + if (sizep) { + *sizep = dt_size; + } return fdt; fail: