From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from userp2130.oracle.com ([156.151.31.86]:33760 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726423AbfGRKvY (ORCPT ); Thu, 18 Jul 2019 06:51:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : sender : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=wwXC44A4PPjZ3DHkTvIb4ZeGgYqv0I1E/ugLXF1u4F4=; b=nMjOmhRnWbxh0V8f9hkERLpNolWgUiAmKXwB2WapKsi3wIjuxZvcxTmQHKTCAXkSPPo8 /zL5pw35T/Mz04cf3hKs9QbbnywHjLVFJ69FKAZq85m9rM3IPLbjRzdQHP9j9liXTuPD UzRhcZnmJ0p7ChdMxPLWIqLn4YCOBHidjYs2U5zfBc19I5MMM3PR+qEHgz9ur7L3IXL4 QcnuRFQD6pWqfydpNqpMkp83+BuHXVkzcJjsXdGdXldX+2A/7XKsSZ2cf2o2s7aREW90 pm3igLZk2yDeGQzyytsu9nq6sYV50X5tW2Ru+TsVLzBpsKWAx7QPDEy2GFerK9SzEEVy EQ== Date: Thu, 18 Jul 2019 13:50:35 +0300 From: Dan Carpenter Subject: Re: Packed struct size issue Message-ID: <20190718105035.GE3111@kadam> References: <20190717134234.GA5551@movementarian.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190717134234.GA5551@movementarian.org> Sender: smatch-owner@vger.kernel.org List-ID: To: John Levon Cc: smatch@vger.kernel.org, andy@omniosce.org, linux-sparse@vger.kernel.org [ resending to the correct Sparse email address ]. On Wed, Jul 17, 2019 at 02:42:34PM +0100, John Levon wrote: > > Andy Fiddaman discovered: > > $ cat ./test.c > #include > #include > > struct t1 { > uint8_t critical_warning; > uint16_t temperature; > uint8_t available_spare; > } __packed; > > _Static_assert(sizeof(struct t1) == 4, "bad size for t1"); > I've added Sparse mailing list to the CC. It looks like the packed attribute is broken on upstream Sparse (from April) as well and I would prefer if they fixed it and I pulled in their fix. It's probably better to use __attribute__((packed)) instead of the __packed macro in the test code. regards, dan carpenter