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

Re: [XEN PATCH 09/13] xen/common: address violations of MISRA C:2012 Directive 4.10


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Simone Ballarin <simone.ballarin@xxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 6 Sep 2023 08:28:41 +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=BwrJ9v0tPmlWK4vV3wJoLU6KbLFOGLut1bdotv1hGhI=; b=TxY9cVm8bSrJmoGyn85Y9+qtpbrYK0zpzH+ViOiAH72b8SjpYTMuZFs1PWEmVtYAxsOVBEiAmLRqQcz5GARCLA/fIjVKZ7ASIubllYQeECr5dAFcOllVFxDDUByPtBX163LXv+MTKqnDkc+ADUZlmrGkpaK1u8F2hmWglYdXxsyY9Cltr/zhNZ/dv9Co6XXvT538xpzJDwx7F6AHC5T4KSbryvtS8eV8ou6jBS3losXM6W4moGciv71ceFpIIPwEA3Ckkns6tZ7HLGS3rGG57cV6LmAWGvh6BkOn/vELnH04N8YPRTyx51d5GKnfeN9im0aQkYi/dNpQyy7fLxfaXA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fwp+vRxmohLt156SPCA1LXo//vaeoNBhmpXZT2aDPjxuchNWoWXHE3TgVOZKxift7UiHopyrnnX29y7IDYw3F/ufg2JSd+3dUvPS82BM37LBE+NIRHA0m9DkATcsvCmFEU0yMVfhH2NJbQKHI5Z5vL8bWUyAb9BMueBPijZZkvG8nZTlvhxt+FAncxfBjnb19a1by/Shs3e+VNcLT6oCTl/YYsOo4aQEgXKGNp3Wf7alyobCeDvTWPLBJ636uz/IR7t4p7XnDda/UPyZFhtxRil8QgTmMUNuhW22+eq9z1LxF2BhGgdiZvgGiYqQ3u8Dwi5/EYqlmZyiNZN//asYBw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: consulting@xxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 06 Sep 2023 06:29:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06.09.2023 00:18, Stefano Stabellini wrote:
> On Thu, 31 Aug 2023, Simone Ballarin wrote:
>> On 31/08/23 15:05, Jan Beulich wrote:
>>> On 31.08.2023 14:54, Simone Ballarin wrote:
>>>> On 31/08/23 13:10, Jan Beulich wrote:
>>>>> On 31.08.2023 12:08, Simone Ballarin wrote:
>>>>>> The danger of multi-inclusion also exists for .c files, why do you
>>>>>> want
>>>>>> to avoid guards for them?
>>>>>
>>>>> Counter question: Why only add guards to some of them? (My personal
>>>>> answer is "Because it's extra clutter.")
>>>>
>>>> It's not "some of them", it's exactly the ones used in an #include
>>>> directive, so I'm not getting your objection.
>>>
>>> My point is that by adding guards only for files we presently use in some
>>> #include directive, we set us up for introducing new violations as soon
>>> as another .c file becomes the subject of an #include.The more that it
>>> is unusual to add guards in .c files, i.e. it is to be expected that
>>> people wouldn't think about this extra Misra requirement.
>>
>> I can agree to partially adopt the directive: I will add a deviation for C
>> files in rules.txt.
> 
> Sorry for the late reply as I was OOO. Please hold on before adding a
> deviation for C files.
> 
> In general, I think including .c files is not common behavior, and
> should be restricted to special cases. We could say that exactly because
> they are special, they follow different rules so we can skip the guards.
> Or we could say that they are still at risk of double-inclusion, hence
> we should be consistent and protect them too. I think we should discuss
> the topic during the next MISRA C meeting.

Just one further remark right here: While including a header file a 2nd
time stands a fair chance of working (i.e. the compiler not spitting out
errors), that would be very unusual for a .c file: Every function or
data item it defines would (in the common case) be already defined.

Jan



 


Rackspace

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