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

Re: [XEN PATCH 4/7] xen/arm: mem_access: address violations of MISRA C:2012 Rule 16.3


  • To: Julien Grall <julien@xxxxxxx>
  • From: Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
  • Date: Wed, 20 Dec 2023 10:36:44 -0500
  • Arc-authentication-results: i=1; mx.zohomail.com; dkim=pass header.i=tklengyel.com; spf=pass smtp.mailfrom=tamas@xxxxxxxxxxxxx; dmarc=pass header.from=<tamas@xxxxxxxxxxxxx>
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703086644; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=6U9a4uRDTNsmkYKcRYzRibfZvUVAXurmlYHaLYqv7Zs=; b=eIlijL4kbLliyucm4H5oHIqpe9VqaSrBpabsj8JEL6GQs5nI3UdNoBRUfu8bhvAKFWdz1RRAf3GV+NKhSJbSmfOSsC/Pk7ADluXuHdp+40BNUuV+4FK8Yj964tKj5wPw2JDPJ4DJBRFwt46/bIKS+ba2HZAf4i52lba2vl5ZMlY=
  • Arc-seal: i=1; a=rsa-sha256; t=1703086644; cv=none; d=zohomail.com; s=zohoarc; b=lkCANh5Kxun4f8cObhv2Araq+bpUiTcmYgk6ijqpGcr+oyUw3kFQLpG1XuWj5puigVQZ0/7yQAPBau9XqlUJYLJ57LgITikukHZ+sz2xlwa/6GNWmZwMn3vH+SWbW4YInZ5UfgSuIxfYk5We3gU3Ml1eq7/8P7eIC5A998kHYvM=
  • Cc: Federico Serafini <federico.serafini@xxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, consulting@xxxxxxxxxxx, Alexandru Isaila <aisaila@xxxxxxxxxxxxxxx>, Petre Pircalabu <ppircalabu@xxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 20 Dec 2023 15:37:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Dec 20, 2023 at 6:53 AM Julien Grall <julien@xxxxxxx> wrote:
>
> Hi Federico,
>
> On 20/12/2023 11:03, Federico Serafini wrote:
> > Refactor of the code to have a break statement at the end of the
> > switch-clause. This addresses violations of Rule 16.3
> > ("An unconditional `break' statement shall terminate every
> > switch-clause").
> > No functional change.
> >
> > Signed-off-by: Federico Serafini <federico.serafini@xxxxxxxxxxx>
> > ---
> >   xen/arch/arm/mem_access.c | 12 ++++++------
> >   1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/xen/arch/arm/mem_access.c b/xen/arch/arm/mem_access.c
> > index 31db846354..fbcb5471f7 100644
> > --- a/xen/arch/arm/mem_access.c
> > +++ b/xen/arch/arm/mem_access.c
> > @@ -168,10 +168,10 @@ p2m_mem_access_check_and_get_page(vaddr_t gva, 
> > unsigned long flag,
> >            * If this was a read then it was because of mem_access, but if 
> > it was
> >            * a write then the original get_page_from_gva fault was correct.
> >            */
> > -        if ( flag == GV2M_READ )
> > -            break;
> > -        else
> > +        if ( flag != GV2M_READ )
> >               goto err;
> > +
> > +        break;
>
> On both hunks, I find the original version better as it is easier to
> match with the comment. I also understand that it wouldn't be great to
> add a deviation for this construct. So maybe we should tweak a bit the
> comment?

Simplifying the if-else to a single if is fine by me. Adjusting the
comment to reflect the new logic would help though, so +1 to Julien's
comment.

Thanks,
Tamas



 


Rackspace

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