[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] xen/arm: asm/atomic.h: Fix MISRA C 2012 Rule 2.5 violation
- To: Julien Grall <julien@xxxxxxx>
- From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
- Date: Thu, 28 Jul 2022 10:26:18 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=2; 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=AcuKVD3NoJzgb4ZjBlCwVtjxzF18jfH0aGMtqb0ImSo=; b=XLy2XJKImvQA4rQfpVMZBVqqo2LKP5ouw1pc0kUFPVtOb3mgx72BdHnKIjJAKp5B37UDL5Qp42dBEDYU4pjEuv/GNNBnC9k9PwpbBnn44SrbBqB3bTwKA0KAmo1zqzZhGzCSeSm/6u22v4QV0S49tNN2lLFMql9lcYpNtt8cdwARN0G3WCh3Wd4E5qBwSzz0RMVqZ1CsIwo/bzZLD16Bk+SBdLrIfZhK8acU16p1wDKw4m5EHHx5mrZ+DXDc+0FM/b+VMzE3gL76lSeGFDZP3JJZ/dwKxl6IW6mYIScFZRwuw0iV9irX9rGE2RvEnMTpc7gzfuwLFXRqwv/b3J8Tzw==
- 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=AcuKVD3NoJzgb4ZjBlCwVtjxzF18jfH0aGMtqb0ImSo=; b=Yeers/MWzdu1kRqQuSokqOJNtZm0ZbUdicRk5A4x88gY/K+OA9jHTZUvdcjl/Ut1mC1+uQ0Sy5YEKEYdR4k5kKspVaUW5enPe5Yu7MzWe/dNsru/rwnOS6+IwZP6Knm5JmAnIW3+bfsP8bOK+z5GfjXHZQ0tRuhzCHBHRmoyeNNEElAXPSIp7PVVvy6N8L9Gd6wrPx+ae8kO//GOhBCHIrvaxbY2TEybsWtis2UPIX35eeTvINX/1Qpoz73vrUcpA4JyblSFBY/ZtcoWfC2swL11/aJsex3wg7HoAQt+KFiI+N2gScRzJurQsmPi1jxcclK5TB66RvpT/P2INT1TRw==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=gsxySUZncXLxvXwyIZrM2czTAogVMFVLCHEMuqzbNfLEhmuqX2lenh6dfWXpnACG/czkWov6oh0oNIEB6NIx/69bG3o3L7jdEqca/a2mUFwIGG5nobJ9hV1Q7todmUPCASUUmPZ/WIHzb8WlIEmcs0hiIeqcKfQKPTwLYIoffzaq9yXyYsE7AOAubZlDJjXHGHdya32CbO1N28AtlYP9DthrtZppXHjlcuuU5zL0MKsECQy4Iob+tlC+86y0rSNlwymy6Jje0qC6en7UNauMTwOLEh1J7RqfYCOv/yLNoQ1t5W8ir3EOdxAc6/0SJRzqe3vG7t2y1nitPN7nSKSxYw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U/+5K0GvQRuGKWDOL6xmu28oRpKP12zop2xtXO2ZEHsS/JLXFM4zqNnyACL4ElUEu8PI8Alo8596nYBTTIddP8gb0motakob18a7AM9RBsEfo6HfABCwls8aDxtpNa4FriWvwoYtH+89/0/2ktkhvlgMJ+VqLok+theyFSK2Sccm0mWpct94daEafHCT5SuNUFBuXoJMtnL7OcDq+EJNxXpVWuvQ/YsHGIn3pzG/cwEyeTMGqP9iDXHFY38EF8Es9qPWBo2p33pTtVJFOxytZg2raRNT/GoZ1yhxTdVIHZqltui9tNS62mPXlxSAMUe2fChNA+1EpT3KQF9CT35/Qg==
- Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Cc: Xenia Ragiadakou <burzalodowa@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Thu, 28 Jul 2022 10:26:32 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
- Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Thread-index: AQHYoc45O9kZLijXrUyjjlrBuGCX1a2SXJWAgAEPNoCAABtvgIAAArUAgAAKKICAAAE+AA==
- Thread-topic: [PATCH 2/2] xen/arm: asm/atomic.h: Fix MISRA C 2012 Rule 2.5 violation
Hi Julien,
> On 28 Jul 2022, at 11:21, Julien Grall <julien@xxxxxxx> wrote:
>
>
>
> On 28/07/2022 10:45, Bertrand Marquis wrote:
>>> On 28 Jul 2022, at 10:35, Julien Grall <julien@xxxxxxx> wrote:
>>>
>>>
>>>
>>> On 28/07/2022 08:57, Bertrand Marquis wrote:
>>>> Hi Julien,
>>>
>>> Hi Bertrand,
>>>
>>>>> On 27 Jul 2022, at 16:46, Julien Grall <julien@xxxxxxx> wrote:
>>>>>
>>>>> Hi Xenia,
>>>>>
>>>>> On 27/07/2022 16:32, Xenia Ragiadakou wrote:
>>>>>> Remove unused macro atomic_xchg().
>>>>>> Signed-off-by: Xenia Ragiadakou <burzalodowa@xxxxxxxxx>
>>>>>> ---
>>>>>> xen/arch/arm/include/asm/atomic.h | 2 --
>>>>>> 1 file changed, 2 deletions(-)
>>>>>> diff --git a/xen/arch/arm/include/asm/atomic.h
>>>>>> b/xen/arch/arm/include/asm/atomic.h
>>>>>> index f5ef744b4b..a2dc125291 100644
>>>>>> --- a/xen/arch/arm/include/asm/atomic.h
>>>>>> +++ b/xen/arch/arm/include/asm/atomic.h
>>>>>> @@ -223,8 +223,6 @@ static inline int atomic_add_unless(atomic_t *v, int
>>>>>> a, int u)
>>>>>> return __atomic_add_unless(v, a, u);
>>>>>> }
>>>>>> -#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
>>>>>> -
>>>>>
>>>>> While I agree this is unused today, the wrapper is quite trivial and part
>>>>> of the generic API (x86 also provides one). So I am not in favor of
>>>>> removing it just to please MISRA.
>>>>>
>>>>> That said, if Bertrand and Stefano agrees with removing it then you
>>>>> should also remove the x86 version to avoid inconsistency.
>>>> I think we can keep this and maybe add a comment on top to document a
>>>> known violation:
>>>> /* TODO: MISRA_VIOLATION 2.5 */
>>>
>>> While I am fine with this goal of the comment (i.e. indicating where Xen is
>>> not MISRA compliant), I think this is one place where I would rather not
>>> want one because it can get stale if someones decide to use the function.
>> I think the one doing that will have to update the comment otherwise we will
>> never manage to have an analysis without findings.
>
> I was under the impression that Xen will never officially follow some of the
> MISRA rules. So I would expect the tools to be able to detect such cases so
> we don't have to add a comment for every deviation on something we will never
> support.
>
>> Having those kind of comments in the code for violation also means that they
>> must be updated if the violation is solved.
>
> Right, but for thing like unused function, this is quite easy to miss by both
> the developer and reviewers. So we are going to end up to comments for
> nothing.
>
>> Maybe we will need a run ignoring those to identify possible violations
>> which are not violations anymore but this might be hard to do.
>
> TBH, I think it would be best if we can teach the tools to ignore certain
> rules.
Definitely it is possible to instruct the tool to ignore this you are right and
for 2.5 we should (for some reason I was under the impression that we said we
would follow 2.5 but accept deviations).
@Xenia: please ignore and do not add a comment for this.
I think we will need to distinguish 2 kind of not following:
- not following at all (disable in the tools)
- accepting some deviations (documented in the code)
As much as we can, I think we should target the second unless we have a lot of
violations.
Cheers
Bertrand
>
> Cheers,
>
> --
> Julien Grall
|