[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN PATCH v2] xen/include: avoid undefined behavior.


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 22 Jun 2023 10:47:06 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DWxRalE6eMZteR+B+PyDdNmd+8tSSz2Nan47LSH2Vac=; b=dOpZzzonjufn/Issnm0/2+ShuUq+z0AghrG5jnpc3rkdHaX2iH9xX9VlK2yv4eL7eGLd7qrD7qigq1wu1FNi0g8syi8BGP6+Z2HHH2Ecyk4kwbwmViwbbbZmPqFZAODNRkSUU3oSyM82Vu/6lKDNXwqnUqzWAt/TiidBvvb85LEGJJm0u7dgwc1MGW63w8YroPZ6JcrEC2etj+Bko2LLYGTz/ooDCeAAbC3C/yifdEn1vR7tMoWrD+IfhDEtZLYLlx8CjerpkSpqBniQBs2Meic56/YL4PaoiyaqLrquIsCUc9Q+kGxl7lmBPApbFH739O9FyVMmizxUsy+2gwbTew==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hKGSQIvQvuk7UrhSG7aOibMz2dF1D0spS6KQ7JXFTaEVqEltaShHC2fpTiWNlME5pz6ZeyYcvRwzKOchSO3KraUiWpcqP8ImnZYZ1R3cOX2ZNPNBdiN94FdJkE3WLB87Q96c6iNxoZM6py//rv008DHucHy8B1IBllWL1mpMVVYncfPnUTRycl7uR+OAzjMMS40Z8mF18IERoJ+MrOlTcIk7BXtaRV50uRjOp8bsc0YPGFWJgoF6bP2fJAnJpB+hbaxWOMnJfFIweKqjwGV5tap0N5xvgMT8fDERM18DpsGQ6x829KwRpTcYRC8BrtssePAXpO2+9VDXBvHSfgz+kg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: sstabellini@xxxxxxxxxx, michal.orzel@xxxxxxx, xenia.ragiadakou@xxxxxxx, ayan.kumar.halder@xxxxxxx, consulting@xxxxxxxxxxx, andrew.cooper3@xxxxxxxxxx, roger.pau@xxxxxxxxxx, bertrand.marquis@xxxxxxx, julien@xxxxxxx, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 22 Jun 2023 08:47:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 22.06.2023 10:15, Nicola Vetrini wrote:
> On 21/06/23 10:48, Jan Beulich wrote:
>> On 21.06.2023 09:58, Nicola Vetrini wrote:
>>> -#define BUILD_BUG_ON_ZERO(cond) sizeof(struct { int:-!!(cond); })
>>> +#define BUILD_BUG_ON_ZERO(cond) \
>>> +    (sizeof(struct { unsigned u : (cond) ? -1 : sizeof(unsigned) * 8; }) - 
>>> sizeof(unsigned))
>>
>> What's wrong with just giving the bitfield a name:
>>
>> #define BUILD_BUG_ON_ZERO(cond) sizeof(struct { int _:-!!(cond); })
>>
> 
> A named bitfield with zero width is not allowed by the standard, which 
> is why the fix introduces a constant positive width. I'll send a v3 
> shortly addressing your previous remarks, though.

Oh, right, but easy to overcome, I think: int _:1 - !!(cond);

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.