From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RwaMb-0001HW-9j for mharc-grub-devel@gnu.org; Sun, 12 Feb 2012 09:25:13 -0500 Received: from eggs.gnu.org ([140.186.70.92]:34584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwaMW-00018w-1O for grub-devel@gnu.org; Sun, 12 Feb 2012 09:25:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RwaMU-0001Ow-A3 for grub-devel@gnu.org; Sun, 12 Feb 2012 09:25:08 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:35998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RwaMU-0001OJ-5U for grub-devel@gnu.org; Sun, 12 Feb 2012 09:25:06 -0500 Received: by wibhj13 with SMTP id hj13so3764911wib.0 for ; Sun, 12 Feb 2012 06:25:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=j9ZpQslA5XMzOlRCXG/eKgGHr2XbmxOc3FJ2I45LKxM=; b=J/fAPwuPOpQY2kgn4Pr6MxfFuNTey7zn8Ch/iKpOc0BrNfEWx8wzS1Ds20+WkY9xap O8fJCuc8mUHW/F8l9qCRT9zfXm4m2qRl/1noux+caTv2BxwtcLBLRhmsZYDHa/bz/AWw ddTOQG+LjfPZWzb3sWZ4iRy5s72Obl4CzXBhQ= Received: by 10.180.92.229 with SMTP id cp5mr19235247wib.8.1329056704973; Sun, 12 Feb 2012 06:25:04 -0800 (PST) Received: from [192.168.1.37] (c2433-1-88-160-112-182.fbx.proxad.net. [88.160.112.182]) by mx.google.com with ESMTPS id ft8sm15431616wib.11.2012.02.12.06.25.03 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 12 Feb 2012 06:25:04 -0800 (PST) Message-ID: <4F37CBBE.8010104@gmail.com> Date: Sun, 12 Feb 2012 15:25:02 +0100 From: =?UTF-8?B?R3LDqWdvaXJlIFN1dHJl?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111114 Iceowl/1.0b2 Icedove/3.1.16 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: GRUB warning level increase References: <4F353F08.5000808@gmail.com> In-Reply-To: <4F353F08.5000808@gmail.com> Content-Type: multipart/mixed; boundary="------------010307020806000406010303" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.169 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Feb 2012 14:25:09 -0000 This is a multi-part message in MIME format. --------------010307020806000406010303 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 02/10/2012 05:00 PM, Vladimir 'φ-coder/phcoder' Serbinenko wrote: > Hello, all. I have increased the warning level in GRUB. This is done for > quicker discovery and correction of the bugs which would be otherwise > hard to track. Mostly it enabled warnings regarding guidelines which are > already followed by GRUB. On Debian GNU/Linux amd64 with GCC 4.6.2, I get a number of warnings triggered by -Wunsafe-loop-optimizations. The first one is: commands/lsacpi.c: In function 'grub_cmd_lsacpi': commands/lsacpi.c:135:3: error: cannot optimize loop, the loop counter may overflow [-Werror=unsafe-loop-optimizations] commands/lsacpi.c:166:3: error: cannot optimize loop, the loop counter may overflow [-Werror=unsafe-loop-optimizations] cc1: all warnings being treated as errors The attached patch fixes it. The remaining ones are, afaics, either false positives or potential overflows in loops of the form: for (i = 1; i <= foo; i++) { ... } where i and foo have the same type (e.g., int). I'm not sure how to properly fix those (declare i with a wider type? replace i by i+1 in the whole loop to make the condition become i < foo?). Grégoire --------------010307020806000406010303 Content-Type: text/x-patch; name="check-len.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="check-len.diff" === modified file 'grub-core/commands/lsacpi.c' --- grub-core/commands/lsacpi.c 2012-02-10 15:48:48 +0000 +++ grub-core/commands/lsacpi.c 2012-02-12 14:03:07 +0000 @@ -132,7 +132,7 @@ disp_acpi_xsdt_table (struct grub_acpi_t disp_acpi_table (t); len = t->length - sizeof (*t); desc = (grub_uint64_t *) (t + 1); - for (; len > 0; desc++, len -= sizeof (*desc)) + for (; len >= sizeof (*desc); desc++, len -= sizeof (*desc)) { #if GRUB_CPU_SIZEOF_VOID_P == 4 if (*desc >= (1ULL << 32)) @@ -163,7 +163,7 @@ disp_acpi_rsdt_table (struct grub_acpi_t disp_acpi_table (t); len = t->length - sizeof (*t); desc = (grub_uint32_t *) (t + 1); - for (; len > 0; desc++, len -= sizeof (*desc)) + for (; len >= sizeof (*desc); desc++, len -= sizeof (*desc)) { t = (struct grub_acpi_table_header *) (grub_addr_t) *desc; --------------010307020806000406010303--