From owner-svn-src-head@freebsd.org Tue Aug 29 19:43:43 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 007C1DE411F; Tue, 29 Aug 2017 19:43:43 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D05936EC1C; Tue, 29 Aug 2017 19:43:41 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 8C62310AF3A; Tue, 29 Aug 2017 15:43:40 -0400 (EDT) From: John Baldwin To: Maxim Sobolev Cc: Ryan Libby , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers Subject: Re: svn commit: r322969 - in head: sbin/mdconfig sys/dev/md sys/sys Date: Tue, 29 Aug 2017 12:41:21 -0700 Message-ID: <5654024.G33lbUi2LU@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: References: <201708281554.v7SFs8fr014268@repo.freebsd.org> <6350259.n2rmZ9RnEY@ralph.baldwin.cx> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Tue, 29 Aug 2017 15:43:40 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Aug 2017 19:43:43 -0000 On Tuesday, August 29, 2017 12:18:18 PM Maxim Sobolev wrote: > John, OK, maybe you are right and the current status quo was just an > accident. I am curious what do you and other people think about expressing > expected structure size and padding more explicitly instead of trying to > accommodate for sometimes intricate play between alignment and type size > with something like char[N]? I.e. along the following lines: > > #if __WORDSIZE < 64 Use #ifdef __LP64__ > #define MD_IOCTL_LEN 436 > #else > #define MD_IOCTL_LEN 448 > #endif > > struct md_ioctl { > union { > struct _md_ioctl_payload { > unsigned version; /* Structure layout version */ > unsigned unit; /* unit number */ > enum md_types type ; /* type of disk */ > char *file; /* pathname of file to mount */ > off_t mediasize; /* size of disk in bytes */ > unsigned sectorsize; /* sectorsize */ > unsigned options; /* options */ > u_int64_t base; /* base address */ > int fwheads; /* firmware heads */ > int fwsectors; /* firmware sectors */ > char *label; /* label of the device */ > } md; > char raw[MD_IOCTL_LEN]; /* payload + padding for future ideas */ > }; > }; > CTASSERT(sizeof(struct md_ioctl) == MD_IOCTL_LEN); This is not the style we use in other structures in FreeBSD. Simply making the existing MDNPAD depend on the #ifdef would be more consistent. For a really good example of how to handle padding, see kinfo_proc which has separate "spare" arrays for int, long, void *, and char. -- John Baldwin