[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: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Thu, 29 Jun 2023 15:04:51 +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=IyCym8qebWLBE0VHeGSJrzaW4U7Q52zCDB4su6wR5DQ=; b=Nx9OnPCusulPz2R9AK+E9ZCTHTGwWN4pnNpsWj92VyGX2E4BzgmvRAcI+ANZWYnZUmS3y9SXmXV0tkYfR9wGWwEUEtGn8rKpdl5gBKqDdbzhTOH4eQh/QcAYfweN7LC90lUWzaQaiaaLnwapCMlwy10VzragJDVlLOx+1/0OMZQEJuGhHzCFvT1xyq+gR+Aa8khLJEVZXyx0HbiUAqm9Y4NpUVHW1QjUkLAPCC1dsEna9boS/0B4Y5uE9wrdk62a/7lTem/IFTzz0TGyDEMjYhVL295l0uC7lMe5/T9v8Koelu1KYdhSDYcxl4mn+akVxmPELFpWn5AR4d3mQcDcig==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EKsBHdrFig7/X1FbggqoS1Olkli5k0MpI+dN+/MndMtb4WQ3hLZLohUMSOA2Pfub0jK4uaw4B1YAYC4HJHsvBEs8IcngBuTFqhgRE7veqyJpunoVem7EE3ri2qrr+AkdJsDpS7uuPxZ2+QhIvyO9wen7oou0p6xTcUjE/OK+mEq/fn5Arhd55/CQFhNrP3zWoanaa+v/bmCtrk1RrBJezd+q25nN5CAuQ2e93xPGcP6Q0c7idcIZh0DbuMSvGpzkQHRx3FHlnleZQdvcswvHlB2HNc4GdHyCjxh07JspR/5EIar3bNJw3mLwqUkabLlT1oX+CPd8V3Uy8mfKm///aw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "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 15:05:25 +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+h4SyA
  • Thread-topic: [XEN PATCH v3 3/3] xen: fix violations of MISRA C:2012 Rule 3.1


> 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.

>         *r &= ~t;
>     }
> }
> diff --git a/xen/include/xen/atomic.h b/xen/include/xen/atomic.h
> index 529213ebbb..fa750a18ae 100644
> --- a/xen/include/xen/atomic.h
> +++ b/xen/include/xen/atomic.h
> @@ -78,7 +78,7 @@ static inline void _atomic_set(atomic_t *v, int i);
>  *      int old = atomic_read(&v);
>  *      int new = old + 1;
>  *      if ( likely(old == atomic_cmpxchg(&v, old, new)) )
> - *          break; // success!
> + *          break;
>  *  }
>  */
> static inline int atomic_cmpxchg(atomic_t *v, int old, int new);
> -- 
> 2.34.1
> 
> 

With the comments addressed:
Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>




 


Rackspace

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