From owner-svn-src-head@freebsd.org Tue Aug 29 19:41:14 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 9024BDE3DAE; Tue, 29 Aug 2017 19:41:14 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: from mail-lf0-x22d.google.com (mail-lf0-x22d.google.com [IPv6:2a00:1450:4010:c07::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 12BA36E969; Tue, 29 Aug 2017 19:41:14 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: by mail-lf0-x22d.google.com with SMTP id d202so17126455lfd.5; Tue, 29 Aug 2017 12:41:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=u7urNHX/XjWVgrfNVTbBQkNk4c8uEalSmozjK/ihYH0=; b=H6J22g4O76YnXH7Je9Czo/MTzgyXZzF1veKa495A3I2X2km1duBor8lMmMDzJUrbNv A9VtZTystKW/NKGPk9rT/7xHQ9AuUOCJuXY4p/aZBdcd4FZPQMYatpgzrUR0wr5mjGaV nZzgC2y7/qCWvqerjpEzpuWU7tQG4yTDeCM77iH1qH5D8vUmZqluphFfkN+QXTPAQxoF 9Jxqcgcgoel0a3hzWPvqHu6G3JM3+PZC2iumvvVqBVgLydsNmBj0NKyTb77P/i5AOZgZ cdQD2sNcOuRu5KN8FPlCSqfmWnz2MsZW1rPCSqnsbOgQiBD7K5X3dTpPFHCcAAiAIhmR qeNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=u7urNHX/XjWVgrfNVTbBQkNk4c8uEalSmozjK/ihYH0=; b=QiUOfzfsG02XfWIn5fU21sTJUmZfXJDn80MK4N0+0gsInqYODliIEOhXfET+C8RFGK ON9sGlJIMTFNw/00wnTih3TAJ1yxpv0rsX44lYlgu7Q46fU5uvZHG67TppFvhbrMfEn4 RUPWVnttnnd2aZEMCThIEwOffUwGyxz9zRngSV0n8p0xb/kSkUijTr1kjVWmwn/wVL7c rsFRV5X/C5gFk5gu+Gf2WZu63pLaAfn0V14UtAzczc93A8qFeMrP/qhTB2hzEFZb5Z6u 4kmjusq7OOSV8J4+94bGKos1bePJeNTHE8++3/y4yfZAnW93zzb/iexKdGXWg5pjN3CT KTpw== X-Gm-Message-State: AHYfb5jomSwQgBd23R3P2huozOul2Vohpde0mMdSV2+pG/U+rneLekjq yRXutWw3D9VqZ+a/2IzvqkK4XSy4ig== X-Received: by 10.46.6.17 with SMTP id 17mr520665ljg.31.1504035672284; Tue, 29 Aug 2017 12:41:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.46.87.73 with HTTP; Tue, 29 Aug 2017 12:41:11 -0700 (PDT) Received: by 10.46.87.73 with HTTP; Tue, 29 Aug 2017 12:41:11 -0700 (PDT) In-Reply-To: References: <201708281554.v7SFs8fr014268@repo.freebsd.org> <2937323.CvTEtZnL2T@ralph.baldwin.cx> <6350259.n2rmZ9RnEY@ralph.baldwin.cx> From: Justin Hibbits Date: Tue, 29 Aug 2017 14:41:11 -0500 Message-ID: Subject: Re: svn commit: r322969 - in head: sbin/mdconfig sys/dev/md sys/sys To: Maxim Sobolev Cc: John Baldwin , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers , Ryan Libby Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 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:41:14 -0000 On Aug 29, 2017 14:18, "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 #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); I've tested that it DTRT on i386 and amd64, need to validate on ARM and MIPS. The code impact should be minimal and easy to apply, i.e. ptr->md_ywz becomes ptr->md.xyz. I like this. Being explicit gives us better guarantees when it comes time to break ABI, rather than it being an accident. - Justin