From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ucu6i-00076E-Ct for qemu-devel@nongnu.org; Thu, 16 May 2013 05:04:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ucu6c-0001hl-CQ for qemu-devel@nongnu.org; Thu, 16 May 2013 05:04:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7647) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ucu6c-0001hO-5G for qemu-devel@nongnu.org; Thu, 16 May 2013 05:04:10 -0400 Date: Thu, 16 May 2013 11:04:07 +0200 From: Stefan Hajnoczi Message-ID: <20130516090407.GI1597@stefanha-thinkpad.redhat.com> References: <1368622839-7084-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1368622839-7084-1-git-send-email-kwolf@redhat.com> Subject: Re: [Qemu-devel] [PATCH] ide-test: Fix endianness problems List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Kevin Wolf , qemu-devel@nongnu.org On Wed, May 15, 2013 at 03:00:39PM +0200, Kevin Wolf wrote: > @@ -355,6 +364,17 @@ static void test_bmdma_teardown(void) > ide_test_quit(); > } > > +static void string_cpu_to_be16(uint16_t *s, size_t bytes) > +{ > + g_assert((bytes & 1) == 0); > + bytes /= 2; > + > + while (bytes--) { > + *s = cpu_to_be16(*s); > + s++; > + } > +} > + > static void test_identify(void) > { > uint8_t data; > @@ -389,10 +409,12 @@ static void test_identify(void) > assert_bit_clear(data, BSY | DF | ERR | DRQ); > > /* Check serial number/version in the buffer */ > - ret = memcmp(&buf[10], "ettsidks ", 20); > + string_cpu_to_be16(&buf[10], 20); > + ret = memcmp(&buf[10], "testdisk ", 20); > g_assert(ret == 0); > > - ret = memcmp(&buf[23], "evsroi n", 8); > + string_cpu_to_be16(&buf[23], 8); > + ret = memcmp(&buf[23], "version ", 8); It would have been simpler to specify string_cpu_to_be16() length in "elements" instead of bytes. Then you can drop the assertion and conversion. Not a problem though. Anthony: Please take this patch without a pull request. I think me sending pull requests for a single late-rc fix doesn't add value. Reviewed-by: Stefan Hajnoczi