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

Re: [XEN PATCH v3 3/3] xen: fix violations of MISRA C:2012 Rule 3.1


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Thu, 29 Jun 2023 19:37:48 +0000
  • Accept-language: en-GB, en-US
  • 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=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=4Io4JZw78Ahog/gMx754TA6O4PeVpjG86K2TDSCQxO4=; b=I8TkkG/E3smVQ0magcAiaGB/xEWqTDF9tAl4oWcnhJtTpTkwJKrPQL+FwqqJ2NhjLIDroYZsalZvfke0TmmiIOqlYoZYnd202BHhF0ptk8Ut3vwgq+nDoFAlmDmW7A6mEp7OnLpZ9RBBvloo2a2Cu4rSgDDNQhHohbyiP4NvQSYmBqL998AJyE0Ip3Bt6VfpbxCtlF0QuV91e5Q4MiVypqWvzsHw5fh4sxOImGZugYM340JrJ3k3mZdkSt+6NPzFFsGG97LEMUhfTG+H8iKt9XMl5JbI87SdP+ef+iML9EgQHgryvdRPrXJciSpW/G6XSVocAfRwuDfupNf8b3+7rw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ackkMgzQygp1+r91vhXRByNSZ+EzRIWXRZahReMrYNypgnVg6u5xC0RvmEPKbwv2JQphVncCVI5swIMXNy7dvVlYy2S2tdYasQ6zyESP9VbwGHh+5QBqtN9Q7qr3f1ESYT+PQ8nXoSfTpEUhGWWjG6bAmwz9Aq70ISAJYZDA1dmLHy+uLLsUeElZWT6yxqK8MrnqU+/aL1TvhGyyeKOk2hImssfkB0aXOZTC+5GdbHNGkBSFXPY3W29h4HDMKH/nz4D41RFUR1qrcPKA9ZVxBrWR+daVQfQmMolvJvRwD3BGmRgFhUlzSPkn3pSN6Oqc1ObapcpJ2/4prI2lB1TjVA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "michal.orzel@xxxxxxx" <michal.orzel@xxxxxxx>, "xenia.ragiadakou@xxxxxxx" <xenia.ragiadakou@xxxxxxx>, "ayan.kumar.halder@xxxxxxx" <ayan.kumar.halder@xxxxxxx>, "consulting@xxxxxxxxxxx" <consulting@xxxxxxxxxxx>, "jbeulich@xxxxxxxx" <jbeulich@xxxxxxxx>, "andrew.cooper3@xxxxxxxxxx" <andrew.cooper3@xxxxxxxxxx>, "roger.pau@xxxxxxxxxx" <roger.pau@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 29 Jun 2023 19:38:15 +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: AQHZqnGGeSRo6D9TDkKPQE/VGyIB1K+h4SyAgABHf4CAAATEAA==
  • Thread-topic: [XEN PATCH v3 3/3] xen: fix violations of MISRA C:2012 Rule 3.1


> On 29 Jun 2023, at 20:20, Stefano Stabellini <sstabellini@xxxxxxxxxx> wrote:
> 
> On Thu, 29 Jun 2023, Luca Fancellu wrote:
>>> On 29 Jun 2023, at 11:06, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> wrote:
>>> 
>>> In the files modified by this patch there are a few occurrences of nested 
>>> '//'
>>> character sequences inside C-style comment blocks, which violate Rule 3.1.
>>> The patch aims to resolve those by removing the nested comments.
>>> 
>>> In the file 'xen/common/xmalloc_tlsf.c' the comment has been replaces by
>> 
>> Typo: s/replaces/replaced/
>> 
>>> an ASSERT, to ensure that the invariant in the comment is enforced.
>>> 
>>> In the file 'xen/include/xen/atomic.h' the nested comment has been removed,
>>> since the code sample is already explained by the preceding comment.
>>> 
>>> Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
>> 
>> Same as patch 2, missing “---"
>> 
>>> Changes:
>>> - Resending the patch with the right maintainers in CC.
>>> Changes in V2:
>>> - Split the patch into a series and reworked the fix;
>>> - Apply the fix to the arm32 `flushtlb.h' file, for consistency.
>>> Changes in V3:
>>> - Replaced commmented-out 'if' with an ASSERT( *fl >= 0 ).
>>> ---
>>> xen/common/xmalloc_tlsf.c | 4 +---
>>> xen/include/xen/atomic.h  | 2 +-
>>> 2 files changed, 2 insertions(+), 4 deletions(-)
>>> 
>>> diff --git a/xen/common/xmalloc_tlsf.c b/xen/common/xmalloc_tlsf.c
>>> index 75bdf18c4e..95affcc571 100644
>>> --- a/xen/common/xmalloc_tlsf.c
>>> +++ b/xen/common/xmalloc_tlsf.c
>>> @@ -140,9 +140,7 @@ static inline void MAPPING_SEARCH(unsigned long *r, int 
>>> *fl, int *sl)
>>>        *fl = flsl(*r) - 1;
>>>        *sl = (*r >> (*fl - MAX_LOG2_SLI)) - MAX_SLI;
>>>        *fl -= FLI_OFFSET;
>>> -        /*if ((*fl -= FLI_OFFSET) < 0) // FL will be always >0!
>>> -         *fl = *sl = 0;
>>> -         */
>>> +        ASSERT( *fl >= 0 );
>> 
>> I’ve checked the codebase for usage of ASSERT, but I’ve not seen use of it 
>> with spaces
>> before and after the condition (like our if conditions) so I think they can 
>> be dropped.
> 
> Yes, that's right. I am OK with this patch but I think we should wait
> for Jan's ack to be sure.
> 
> An alternative that I feel more comfortable in Acking myself because it
> doesn't change the semantics of this code would be to change the 3 lines
> of code above with this:
> 
> /*
> * ; FL will be always >0!
> * if ((*fl -= FLI_OFFSET) < 0)
> *     fl = *sl = 0;
> */

Hi Stefano,

I think we would have a violation for the Directive 4.4 (Sections of code 
should not be commented out)
in this case, however it’s not listed in rules.rst and I don’t remember where 
to look to know if it was
taken into consideration for the adoption in Xen in the “tailoring” phase.





 


Rackspace

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