From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Rdwne-0000Tj-OA for mharc-grub-devel@gnu.org; Thu, 22 Dec 2011 23:32:06 -0500 Received: from eggs.gnu.org ([140.186.70.92]:43400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rdwnb-0000Sm-Ea for grub-devel@gnu.org; Thu, 22 Dec 2011 23:32:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rdwna-00082x-85 for grub-devel@gnu.org; Thu, 22 Dec 2011 23:32:03 -0500 Received: from mail-qy0-f169.google.com ([209.85.216.169]:57531) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rdwna-00082l-5h for grub-devel@gnu.org; Thu, 22 Dec 2011 23:32:02 -0500 Received: by qcsd17 with SMTP id d17so6161409qcs.0 for ; Thu, 22 Dec 2011 20:32:01 -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:content-transfer-encoding; bh=l4Gh3IoeW+rClAAaBA+zcvVfIY1hZ+f7lm0Xd7dnJjA=; b=EU1VEf7FSnftwov//gufHank3WhI/mCAeSvDSNW9t2VIhnjddtjPsqH1139dOxzFOZ qHPCT+b5uBdmDDlVfGgG+fHIMnZHOcupK1A4BkGFsxPuNzDWmOfgjf1Bom0ySLcLU19w 6/I1vRfBWsXchau/FMRgPL4Y81ziSA5OgZ1n4= Received: by 10.224.42.140 with SMTP id s12mr10335690qae.87.1324614720975; Thu, 22 Dec 2011 20:32:00 -0800 (PST) Received: from [127.0.0.1] (pool-96-237-17-111.bstnma.east.verizon.net. [96.237.17.111]) by mx.google.com with ESMTPS id dh10sm21645472qab.19.2011.12.22.20.31.59 (version=SSLv3 cipher=OTHER); Thu, 22 Dec 2011 20:32:00 -0800 (PST) Message-ID: <4EF40444.5060303@gmail.com> Date: Thu, 22 Dec 2011 23:32:04 -0500 From: Peter Lustig User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111220 Thunderbird/9.0 MIME-Version: 1.0 To: grub-devel@gnu.org Subject: Re: New command to check NT's hibernation state References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.216.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: Fri, 23 Dec 2011 04:32:04 -0000 On 12/22/2011 13:10, Vladimir 'phcoder' Serbinenko wrote: > On 18.12.2011 04:16, Peter Lustig wrote: >> > /* Return SUCCESS if magic indicates file is active; else return FAILURE */ >> > if (!grub_strncasecmp ("hibr", hibr_file_magic, magic_size)) > What's the reason to use strncasecmp? Does the case changes? Usually > memcmp is the right way to check the signature. This also avoids the > need of memset and trailing zero byte. It can be either {'h', 'i', 'b', 'r'} (for Windows XP) or {'H', 'I', 'B', 'R'} (for Windows Vista/7). Technically I should only be checking for these two values, but it is unlikely that the magic would have mixed case. The only other values I know (from ) that it can assume are {'w', 'a', 'k', 'e'}, {'l', 'i', 'n', 'k'}, and {'\0', '\0', '\0', '\0'}. Using strncasecmp() seemed like a simple way to approach the problem.