All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Tamas K Lengyel <tamas.k.lengyel@gmail.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
	Julien Grall <julien.grall@arm.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	stefanos@xilinx.com
Subject: Re: [PATCH 2/4] xen/arm: initialize access
Date: Tue, 16 Oct 2018 09:14:19 +0800 (CST)	[thread overview]
Message-ID: <alpine.DEB.2.10.1810160911160.4859@sstabellini-ThinkPad-X260> (raw)
In-Reply-To: <CABfawhmtLksbC6pyp2SuH=sPR5E6mndwbMMpucBca3nUpDUbqQ@mail.gmail.com>

On Mon, 15 Oct 2018, Tamas K Lengyel wrote:
> On Mon, Oct 15, 2018 at 3:57 AM Stefano Stabellini
> <sstabellini@kernel.org> wrote:
> >
> > Initialize variable *access before returning it back to the caller.
> >
> > Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
> > ---
> >  xen/arch/arm/mem_access.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/xen/arch/arm/mem_access.c b/xen/arch/arm/mem_access.c
> > index ba4ec78..10ab308 100644
> > --- a/xen/arch/arm/mem_access.c
> > +++ b/xen/arch/arm/mem_access.c
> > @@ -47,6 +47,7 @@ static int __p2m_get_mem_access(struct domain *d, gfn_t gfn,
> >      };
> >
> >      ASSERT(p2m_is_locked(p2m));
> > +    *access = XENMEM_access_n;
> 
>  Why XENMEM_access_n and why set this at all here?

Hi Tamas,

Yes, I missed an explanation. Initializing variables before passing them
as parameter or as a return value to a function is a safety
certification requirement. Also, it makes the code a bit nicer.

In the specific case of this function, *access is initialized before
returning in all cases but the return -ESRCH case. I thought the nicer
way to make sure *access is always initialized, making the code more
robust, would be to initialize *access at the beginning of the function
with a restrictive value.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-10-16  1:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-15  9:55 [PATCH 0/4] misc safety certification fixes Stefano Stabellini
2018-10-15  9:56 ` [PATCH 1/4] xen/arm: initialize target Stefano Stabellini
2018-10-15 13:07   ` Julien Grall
2018-10-15  9:56 ` [PATCH 2/4] xen/arm: initialize access Stefano Stabellini
2018-10-15 13:08   ` Julien Grall
2018-10-15 15:15   ` Tamas K Lengyel
2018-10-16  1:14     ` Stefano Stabellini [this message]
2018-10-16 15:24       ` Tamas K Lengyel
2018-10-17 13:53         ` Stefano Stabellini
2018-10-15  9:56 ` [PATCH 3/4] xen: introduce __symbol Stefano Stabellini
2018-10-15 12:20   ` Andrew Cooper
2018-10-15 13:20   ` Julien Grall
2018-10-16  1:34     ` Stefano Stabellini
2018-10-16 10:06       ` Andrew Cooper
2018-10-16 13:01         ` Stefano Stabellini
2018-10-25 10:37   ` Jan Beulich
2018-10-15  9:56 ` [PATCH 4/4] xen: use __symbol everywhere Stefano Stabellini
2018-10-25 10:39   ` Jan Beulich
2018-11-06 21:47     ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.10.1810160911160.4859@sstabellini-ThinkPad-X260 \
    --to=sstabellini@kernel.org \
    --cc=julien.grall@arm.com \
    --cc=stefanos@xilinx.com \
    --cc=tamas.k.lengyel@gmail.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.