From owner-freebsd-embedded@FreeBSD.ORG Wed Nov 6 23:00:38 2013 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id BA428E66; Wed, 6 Nov 2013 23:00:38 +0000 (UTC) (envelope-from kp@vega.codepro.be) Received: from venus.codepro.be (venus.codepro.be [IPv6:2a01:4f8:162:1127::2]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7E12D25E7; Wed, 6 Nov 2013 23:00:38 +0000 (UTC) Received: from vega.codepro.be (unknown [172.16.1.3]) by venus.codepro.be (Postfix) with ESMTP id 4347F9831; Thu, 7 Nov 2013 00:00:36 +0100 (CET) Received: by vega.codepro.be (Postfix, from userid 1001) id 3A97BDD22; Thu, 7 Nov 2013 00:00:35 +0100 (CET) Date: Thu, 7 Nov 2013 00:00:35 +0100 From: Kristof Provost To: Warner Losh Subject: Re: Incorrect struct onfi_params definition Message-ID: <20131106230035.GG58987@vega.codepro.be> References: <20131106212855.GF58987@vega.codepro.be> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-PGP-Fingerprint: E114 D9EA 909E D469 8F57 17A5 7D15 91C6 9EFA F286 User-Agent: Mutt/1.5.22 (2013-10-16) Cc: Grzegorz Bernacki , freebsd-embedded@freebsd.org X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Nov 2013 23:00:38 -0000 On 2013-11-06 13:56:46 (-0800), Warner Losh wrote: > On Nov 6, 2013, at 1:28 PM, Kristof Provost wrote: > > The definition of struct onfi_params in sys/dev/nand/nand.h is > > incorrect. The total structure size should be 256 bytes, but it's only > > 176 bytes. > > > > That's because the vendor_spec array was declared as being 8 bytes, > > rather than the 88 bytes it should be. Clearly a typo. > > > > This patch should fix it: > > I'd add a CT_ASSERT sizeof(onfi_params) == 256 too. > Ok, here's an updated patch: diff --git a/sys/dev/nand/nand.h b/sys/dev/nand/nand.h index 0d6d7b4..6e3fc04 100644 --- a/sys/dev/nand/nand.h +++ b/sys/dev/nand/nand.h @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -217,9 +218,10 @@ struct onfi_params { uint8_t driver_strength_support; uint8_t res4[12]; uint16_t vendor_rev; - uint8_t vendor_spec[8]; + uint8_t vendor_spec[88]; uint16_t crc; }__attribute__((packed)); +CTASSERT(sizeof(struct onfi_params) == 256); struct nand_ecc_data { int eccsize; /* Number of data bytes per ECC step */ Regards, Kristof