From patchwork Thu Jun 21 04:51:24 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: 166214 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 8DA72B6FF8 for ; Thu, 21 Jun 2012 14:51:53 +1000 (EST) Received: from localhost ([::1]:56940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShZN1-0005Uq-C4 for incoming@patchwork.ozlabs.org; Thu, 21 Jun 2012 00:51:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShZMu-0005TX-CC for qemu-devel@nongnu.org; Thu, 21 Jun 2012 00:51:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ShZMs-0003lJ-4Q for qemu-devel@nongnu.org; Thu, 21 Jun 2012 00:51:43 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:62357) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ShZMr-0003kO-U0 for qemu-devel@nongnu.org; Thu, 21 Jun 2012 00:51:42 -0400 Received: by dadn2 with SMTP id n2so331918dad.4 for ; Wed, 20 Jun 2012 21:51:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=37m6OXvxihrVutW45e8Q0ZJSudkgBs9AAbtvb6RCYH8=; b=SxIlamlLPBa04rQrp3TrpK0Jl7dWf2L3NWEwh+zoSgaRtuTBjbnDxWq9ieYn+GKLMi wLgEUK3yoHamm01ESXPRGgQ8EhD6tnz/XLojqU/rZPlfGZNmeliVfX/HU9PXzrLuGSpJ zZ9DJlJgTeDuRcL/U3dDmWhlTeT3lhHPAG8SFqVVEwdhmPJapygxJBIv7dFZtDE18m4X S9PFlAO8ITVHXyVy9gyuXJzbHdgExOe5MGPgC6PNyZGXFiOouXNrCd7SLUNEHvw7gId/ pDHVXY6DvB9BOeI0YJyD0jo3ykeQPwkKAemOBRoLUtaZppHngpJYeF404V1IJ7ZWVqUC RxfA== Received: by 10.68.228.2 with SMTP id se2mr83464385pbc.109.1340254299189; Wed, 20 Jun 2012 21:51:39 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id np8sm34460969pbc.71.2012.06.20.21.51.35 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 20 Jun 2012 21:51:38 -0700 (PDT) From: "Peter A. G. Crosthwaite" To: qemu-devel@nongnu.org, edgar.iglesias@gmail.com, qemu-trivial@nongnu.org Date: Thu, 21 Jun 2012 14:51:24 +1000 Message-Id: <1340254284-20415-1-git-send-email-peter.crosthwaite@petalogix.com> X-Mailer: git-send-email 1.7.3.2 X-Gm-Message-State: ALoCoQmBfvV7ps3RK/Y0Wa0AI+Eh97SsI6fE+bSPncipVZX1nR7V/WR72wU4NOYf/Zm4MEqJVlE2 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.45 Cc: peter.crosthwaite@petalogix.com, john.williams@petalogix.com Subject: [Qemu-devel] [PATCH v1] 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 86a694c..0ed0256 100644 --- a/device_tree.c +++ b/device_tree.c @@ -32,7 +32,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", @@ -65,7 +67,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: