From patchwork Tue Aug 5 09:57:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 376638 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 91893140087 for ; Tue, 5 Aug 2014 20:03:42 +1000 (EST) Received: from localhost ([::1]:58334 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEbam-0004Eo-OC for incoming@patchwork.ozlabs.org; Tue, 05 Aug 2014 06:03:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEbZp-00033d-0K for qemu-devel@nongnu.org; Tue, 05 Aug 2014 06:02:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XEbZi-0002JR-SE for qemu-devel@nongnu.org; Tue, 05 Aug 2014 06:02:40 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:47458 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEbXW-0001YH-GR for qemu-devel@nongnu.org; Tue, 05 Aug 2014 06:00:18 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaro.local) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1XEbiU-0007z4-QA; Tue, 05 Aug 2014 12:11:38 +0200 References: <1407152873-16772-1-git-send-email-rjones@redhat.com> <1407152873-16772-2-git-send-email-rjones@redhat.com> From: Alex =?utf-8?Q?Benn=C3=A9e?= To: "Richard W.M. Jones" Date: Tue, 05 Aug 2014 10:57:26 +0100 In-reply-to: <1407152873-16772-2-git-send-email-rjones@redhat.com> Message-ID: <874mxrl0hz.fsf@linaro.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: alex.bennee@linaro.org X-SA-Exim-Scanned: No (on socrates.bennee.com); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 88.198.71.155 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH v5 1/2] loader: Add load_image_gzipped function. 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 Richard W.M. Jones writes: > As the name suggests this lets you load a ROM/disk image that is > gzipped. It is uncompressed before storing it in guest memory. > > Signed-off-by: Richard W.M. Jones > + /* Is it a gzip-compressed file? */ > + if (len < 2 || > + compressed_data[0] != '\x1f' || > + compressed_data[1] != '\x8b') { > + goto out; > + } Hmm serves me right for not compiling this first. I had to explicit literals to get this to compile: Modified hw/core/loader.c Otherwise I get: hw/core/loader.c: In function ‘load_image_gzipped’: hw/core/loader.c:603:9: error: comparison is always true due to limited range of data type [-Werror=type-limits] compressed_data[1] != '\x8b') { diff --git a/hw/core/loader.c b/hw/core/loader.c index e773aab..83136e8 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -599,8 +599,8 @@ int load_image_gzipped(const char *filename, hwaddr addr, uint64_t max_sz) /* Is it a gzip-compressed file? */ if (len < 2 || - compressed_data[0] != '\x1f' || - compressed_data[1] != '\x8b') { + compressed_data[0] != 0x1f || + compressed_data[1] != 0x8b ) { goto out; }