[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 09:45:31 +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=IZIynvujiCOEswQ21LIeQ0Ct0RPettGAUKixNuXN3nA=; b=GuRptSGCkYOsWIL6H7pL60h84fok5GfqVGMdgsip+uMegPyMxge9jETPhA0gG8jIUEgvvYP4MaCWSPd0N9KEuS7lYJZ/kWHKEiUX3M91aaI8G9+qJV0PKUXtKjHM3bOEYAW+x0tRuF6yn7izdgV0vBYYvaj7aBeXUiJ22RpRaYmlVbG+QwCSlRoVx7WW5r4EouoRRR0hc9GMus6xsX/rN4YmMMOR30iqIVfQ2w2hCX/rXymI6gcOkH3phTLwIXUCeapuZWJhwIdqxs+8+NpHPBLIbFxnr+EVDush2Zn0JkUw/bLSyM7wTWiaf+pz13NnqAZ7f8smAH536ZFAZIuhpw==
  • 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=IZIynvujiCOEswQ21LIeQ0Ct0RPettGAUKixNuXN3nA=; b=SIllx8t0huBWWdFIqNnwt2b2BjNrce8rGyT3u/OWKFkoz1gu8s+6teAvyMOjW62GPxekEtZ/awxQVp6Uosdlw9NpDKZQMmMNDaSSCtiGh8GO7j2gAEOQAMeEGrd3/tAVyHMk+bDvgEaXdwedD8BNoBz/+hZbu+qhhrtbx2SV/92/34nkUt9azIHYTcAV07h2nzzOUwYqgSBCGO6buDBQbmRApNy9s0n06TMvKIMjhIvSM+Rdj8oe9TQVzfYAzuJuSZWaMviSntrOZXAkvxsOpjQhi9tBHpVZ9mPWUFBsepNbomJwVt81bnbjlQHkx9jeD5OJM5g3/OIQGIlJKPFx9Q==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=i5HLOiu9HDFDlqEEtz8jx1uHvgeYA6fxgVajrQ3yx4MpG9CoSOx9G6PhI57jOgAelDsnXlncSZPNBmacDsfqNmvdrbMpKZJy/VIxo0WqfYf6q53HMNJm9GUsz9DHm9fRt8OdRAfz5KyPen3Ln2FzwBNKdsJJJ54VT37boK73eAo5MITcTKQt09Mko0T4Xy+sf2WBoCuI1gHltG0DM09hT6BddwjRh1hop2B3cwJOaYJMzDhg5y+WffVSNz3dzCWyAwXkpjwsgFrGnK6sUXbOT0/hlTKlPtzLZj30bQtMU9fkz0t7jvtb7Ljdnwevm8nWSC7cKRZ8eCMT7VhFBS1aMw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XX6wau96tdcTLFGeqQQ269osijeOUaiHkzECFqXeU54ai+/hZtbhyUwJ4E4P0xmK3fe94PzskBMhkq0GVjMdFHJYzO8R31vtcaWCA4dNrdsDujarciTa2jepuLxGUkkDFXJW2UvQ8V9/2/Ur9QJuFrC4rkAVQE4vwBnXOs5yFTkJnqM14zNO866bRUNAaG7gIhivJ+v4ZYhNQlah7E7C03gBp28mrDmoMivzhsQr7oZj9rffs8KC5y2cLXBukjJsma5zA7Oi9NZqaXP5lkhUa4tf4LT6sKiGQEUxn0vRFvb6iFSqXEcVDr4MeofZaVRv7C6fDYMRZwPDOIcOmGCCqQ==
  • 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 09:45:52 +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: AQHYoc45O9kZLijXrUyjjlrBuGCX1a2SXJWAgAEPNoCAABtvgIAAArUA
  • 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 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.
Having those kind of comments in the code for violation also means that they 
must be updated if the violation is solved.

Maybe we will need a run ignoring those to identify possible violations which 
are not violations anymore but this might be hard to do.

Cheers
Bertrand

> 
> Cheers,
> 
> -- 
> Julien Grall




 


Rackspace

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