From patchwork Fri Dec 14 14:41:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 153871 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2164137ljp; Fri, 14 Dec 2018 06:54:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/UNrm0TJYVsdN8fRYweaoTpZthe7qfLQHdN4pwPD8boyJ3bx9tMlkhAlhmX6Cy1tOpWs7Kh X-Received: by 2002:aed:31c5:: with SMTP id 63mr3061600qth.385.1544799278256; Fri, 14 Dec 2018 06:54:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544799278; cv=none; d=google.com; s=arc-20160816; b=VrILtdbI7lqlhTNjiQbueB2+qsWPcpR3WzThsgUz/azgWG868GFMKFweHsACAK2FjC F4UHvYTuCGj7DoUEhql56X3BBlNNT/7Tm4BcMf7o99Jy0YPpOiVYafc3+nE5zxL2XE+W 9fKBuRC3BWTwz9+XPb3TBqo338tUlyHzN7l5tB/okcHqbG2ZwldPKq7RDlCZvGxbxTzS Eswb7H7Y+VbLETlHWe3hIq5ys6EAqJtclHfaE5elk1WiERlq1AjPsKkDN6Wvkh9GxL6e z+UWGrnYPSAMfIAH4BfHc6rS+zZFQ+CLe8Lq4xfy6p5Qdu/IPqKf/kS9ONJoKoJwScv/ QfJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=67NUuZEh6hl7u0ElUf/0ghf8ALMseJ+QqFALOLaub/k=; b=jbfa+foe94CCPM4e6uOFLgfGzdtW7eKsQJA2gLLUDkGgWJuxvRp8jKx/VkobV4yxB6 gnsgxj4IF8K+aV4GouDVhpg8Hr44vegrHh9Cf/3N4sArnTFrwgKcAWBsvt6FSqr+1tSX RA4aU5rDab3yVsmPUYMieeC55cBqiLvfcD7DMs2bZoiRMOb4se3+SRFuk6CxlDDSr1jq FxY3+MV862/P8if/3v7zyMaGBlnqShXdHk4WxpX+EDiRGK/7UuFyGfxme5DHQLvsJA6e 31YSWI2vk4OuIcge3Kjty0Tm+q9IyretnmaX82ZC7ixf/VDjQmwuqPPgQIBwdF0vrDrs Uxdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aSztM7Vm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p88si3039486qtd.156.2018.12.14.06.54.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:54:38 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=aSztM7Vm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:33932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXorN-0001xn-M6 for patch@linaro.org; Fri, 14 Dec 2018 09:54:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXofe-0008Rx-8F for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXofb-0004Kk-3Y for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:30 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:39779) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXofa-0004Jx-T3 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 09:42:27 -0500 Received: by mail-wr1-x430.google.com with SMTP id t27so5674372wra.6 for ; Fri, 14 Dec 2018 06:42:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=67NUuZEh6hl7u0ElUf/0ghf8ALMseJ+QqFALOLaub/k=; b=aSztM7VmXTmbeQzQ54+dQeQMvYI4t+vtUmn9CWTK/Ba6kH76yem9qyUx1gpkzpb8v4 kI31n1I4SqfrubBxIuybfP+RsMDMpeQxcoDgCTEykwnAaWEo6RxQvFPXtAyKwApaJShf ncVXJ3Y98j3oNZR7Zlo5E7rPOTqYVy0CwJ0fI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=67NUuZEh6hl7u0ElUf/0ghf8ALMseJ+QqFALOLaub/k=; b=Wt4/bCG/1SgF17ZQDqXbJFDbyhznrzkj0nUm0LFPm6BwG9GKbDWuKlESxPeu5uNDrx YAe/LeuNeG9OfknNk4WIwxVfmYU2osQMsR5rDAE+qhFCAi+jVfUubHvuDfrhYN7hplqZ azSNAsIuqOoBbogLqUsn1OplMAXKkZ0KlgS5D/FopbwQ8vUg6bvau2BHZHTUT8CiBrwu vfMP3SN4yahpqwgcsvsoYMITaVaka7bV2dPjgT9DWyLCVSZsheTlAHqWUFPSbkbVzMCk flCcdrFHql8kBnqiK+UuUQAiPrcwMjHHLwCyjhIufLOunIHtVUet4ZK+P2eEIH0X56g1 Wd3Q== X-Gm-Message-State: AA+aEWbC8SpRrXxxXDfh/hQQjP3QJzVLT0tqySgkoO1ubknaPlwtCIuf XJSoXm1Qi5BpXgCLaSibpIz6KgcJhmg= X-Received: by 2002:a5d:620f:: with SMTP id y15mr2774984wru.314.1544798545287; Fri, 14 Dec 2018 06:42:25 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id m6sm3263204wrv.24.2018.12.14.06.42.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:42:24 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 14 Dec 2018 14:41:59 +0000 Message-Id: <20181214144214.1260-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181214144214.1260-1-peter.maydell@linaro.org> References: <20181214144214.1260-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::430 Subject: [Qemu-devel] [PULL 07/22] hw/ppc/mac_newworld, mac_oldworld: Don't use load_image() 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Use the glib g_file_get_contents() function instead, which does the whole "allocate memory for the file and read it in" operation. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Reviewed-by: Eric Blake Acked-by: David Gibson Message-id: 20181130151712.2312-2-peter.maydell@linaro.org --- hw/ppc/mac_newworld.c | 10 ++++------ hw/ppc/mac_oldworld.c | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) -- 2.19.2 diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 14273a123e5..7e45afae7c5 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -127,8 +127,7 @@ static void ppc_core99_init(MachineState *machine) MACIOIDEState *macio_ide; BusState *adb_bus; MacIONVRAMState *nvr; - int bios_size, ndrv_size; - uint8_t *ndrv_file; + int bios_size; int ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; @@ -510,11 +509,10 @@ static void ppc_core99_init(MachineState *machine) /* MacOS NDRV VGA driver */ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, NDRV_VGA_FILENAME); if (filename) { - ndrv_size = get_image_size(filename); - if (ndrv_size != -1) { - ndrv_file = g_malloc(ndrv_size); - ndrv_size = load_image(filename, ndrv_file); + gchar *ndrv_file; + gsize ndrv_size; + if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) { fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size); } g_free(filename); diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 9891c325a9b..817f70e52cf 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -99,8 +99,7 @@ static void ppc_heathrow_init(MachineState *machine) SysBusDevice *s; DeviceState *dev, *pic_dev; BusState *adb_bus; - int bios_size, ndrv_size; - uint8_t *ndrv_file; + int bios_size; uint16_t ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; @@ -361,11 +360,10 @@ static void ppc_heathrow_init(MachineState *machine) /* MacOS NDRV VGA driver */ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, NDRV_VGA_FILENAME); if (filename) { - ndrv_size = get_image_size(filename); - if (ndrv_size != -1) { - ndrv_file = g_malloc(ndrv_size); - ndrv_size = load_image(filename, ndrv_file); + gchar *ndrv_file; + gsize ndrv_size; + if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) { fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size); } g_free(filename);