From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Carpenter Subject: Re: [PATCH] drivers: staging: lustre: lustre: include: add "__attribute__((packed))" for the related union Date: Mon, 20 Jan 2014 15:30:46 +0300 Message-ID: <20140120123045.GV7444@mwanda> References: <52DA4E6A.1000308@gmail.com> <20140118100547.GS7444@mwanda> <52DA56C2.5010802@gmail.com> <20140118142404.GT7444@mwanda> <52DBA3D4.3090308@gmail.com> <52DD0EFF.2010305@imgtec.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <52DD0EFF.2010305@imgtec.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: driverdev-devel-bounces@linuxdriverproject.org To: James Hogan Cc: devel@driverdev.osuosl.org, andreas.dilger@intel.com, Chen Gang , Greg KH , bergwolf@gmail.com, "linux-kernel@vger.kernel.org" , oleg.drokin@intel.com, jacques-charles.lafoucriere@cea.fr, jinshan.xiong@intel.com, linux-metag@vger.kernel.org Ah. From so metag is a new arch and not a compiler like the changelog says. On Mon, Jan 20, 2014 at 11:56:47AM +0000, James Hogan wrote: > struct a { > struct b { > unsigned int x; > unsigned short y; > } x; > unsigned short y; > } __packed; This is not the code we are discussing. It should look like: struct a { union { short x; short y; } short z; }; Any normal person would assume that sizeof(struct a) would be 4 but apparently on metag it is 8. That totally defeats the point of using a union in the first place. It's easy enough to add a __packed to the lustre declaration but I expect this to cause an endless stream of bugs. It it is really stupid. regards, dan carpenter