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

Re: [PATCH v2] misra: add deviation for MISRA C Rule 11.3


  • To: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Thu, 25 Sep 2025 19:11:08 +0000
  • Accept-language: en-US, uk-UA, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=lewHeEG9bcwJLUXMtZ+779xDAXJ2awm1T9kV5kQc5V0=; b=e8/yPYwceSLDauwq/dpgquOqddkcdswdusHNyQDy8cFgW1q8DffiRV0Tsql0Mjjyq7dfGH4/SH0jD+xmqfR6oMue6IuqpRsqsQA0YcmiD0r0dM6eG/s7EM/J31AK7KCDruXTY8gAxspUgimla/Ez3uAOSz+cLKTOcyHxH43NPBMM1IDxHlv1mBV4wgJQ+HYNzu6JM1NKPYjQcw4P5X5SCkci3s2XiMmMqt+sLduOtZZEPJzsQz61DcESZH0avDt+/t+x3R7+yZ3Ghkze9EOGYdDFFrvyX8FjUoEC7WhidOMyx4WloIAB7YAVLhOq2v0bbtDamcGV33n75khDEDn5Ig==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xH46NqBWLchb5Olav/R5+Le4KSBQltCq0SWpO85Mqn4l6WS+ZOoSd53FhlwfxJiFuOMsvVykiwD59td8awBTNc9hSZNWCCgdocVvkKJXQq2Jlg0+9vFgYwbqd3xHXWS0We2GNXpTb/0nP7i2vIs5RT8/MAvYrnUeLvyk1tRw86NbxDpRBKZbeqGK2VkqQDIwd+uRYG5abob5XiXkpIJK/kw/SkeRDj3DXMpzAkNpz6yBtcv+VYgXPneJwoGoGHkT3zr6C4A6vm0rkyCYeMSWBYCz+OK/4GCOPvdGYUl+fbap4WEPSyIlwIaXGlieE2ZCYJoK8v8JVIJDcOuBj45bGg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Doug Goldstein <cardoe@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Thu, 25 Sep 2025 19:11:24 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcFRxkNZTwf+a94EKUOod0hf+3z7RzKlMAgDFLvoA=
  • Thread-topic: [PATCH v2] misra: add deviation for MISRA C Rule 11.3


On 8/25/25 13:23, Jan Beulich wrote:
> On 24.08.2025 19:27, Dmytro Prokopchuk1 wrote:
>> MISRA C Rule 11.3 states: "A cast shall not be performed between a pointer
>> to object type and a pointer to a different object type."
>>
>> Violations of this rule arise due to the 'container_of()' macro, which casts
>> a member of a structure to its containing structure:
>>      container_of(ptr, type, member) ({                             \
>>             typeof_field(type, member) *__mptr = (ptr);             \
>>             (type *)( (char *)__mptr - offsetof(type,member) );})
>>
>> The 'container_of()' macro is safe because it relies on the standardized and
>> well-defined 'offsetof()' macro to calculate the memory address of the
>> containing structure, while assuming proper alignment and ensuring no
>> undefined behavior, provided that the input pointer is valid and points to
>> the specified member.
> 
> I may have said so before: This all reads okay to me, just that I'm unsure
> it would actually be convincing to an assessor. The "provided that ..." is
> a pretty strong requirement, which isn't overly hard to get wrong. Stefano,
> Nicola - what's your take here?
> 
> Jan

Stefano, Nicola,

gentle reminder.

Dmytro.

 


Rackspace

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