All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	dgdegra@tycho.nsa.gov, xen-devel@lists.xenproject.org
Subject: Re: [PATCH] xen/xsm: Shut up GCC 5.1.1 warnings.
Date: Wed, 16 Sep 2015 16:14:27 +0100	[thread overview]
Message-ID: <55F98753.8020205@citrix.com> (raw)
In-Reply-To: <1442411117-19107-1-git-send-email-konrad.wilk@oracle.com>

Hi Konrad,

On 16/09/15 14:45, Konrad Rzeszutek Wilk wrote:
> policydb.c: In function ‘user_read’:
> policydb.c:1443:26: error: ‘buf[2]’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>          usrdatum->bounds = le32_to_cpu(buf[2]);
>                           ^
> cc1: all warnings being treated as errors
> 
> Which makes no sense, as :
>  1). A couple of lines above it is being filled (buf[2]).

Not in every case, if p->policyvers < POLICYDB_VERSION_BOUNDARY, buf[2]
won't be initialized.

>  2). There are other instances of this which are not triggering this
>      failure.
> But GCC insists, and this patch stops the failures.
> 
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
>  xen/xsm/flask/ss/policydb.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/xen/xsm/flask/ss/policydb.c b/xen/xsm/flask/ss/policydb.c
> index a1060b1..cee259c 100644
> --- a/xen/xsm/flask/ss/policydb.c
> +++ b/xen/xsm/flask/ss/policydb.c
> @@ -1274,6 +1274,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp)
>      if ( rc < 0 )
>          goto bad;
>  
> +    buf[2] = 0; /* To shut up compiler warnings. */

By doing this, you will override buf[2] when the policy version >=
POLICYDB_VERSION_BOUNDARY.

>      len = le32_to_cpu(buf[0]);
>      role->value = le32_to_cpu(buf[1]);
>      if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
> @@ -1437,6 +1438,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp)
>      if ( rc < 0 )
>          goto bad;
>  
> +    buf[2] = 0; /* To shut up compiler warnings. */

Ditto.

>      len = le32_to_cpu(buf[0]);
>      usrdatum->value = le32_to_cpu(buf[1]);
>      if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
> 

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2015-09-16 15:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16 13:45 [PATCH] xen/xsm: Shut up GCC 5.1.1 warnings Konrad Rzeszutek Wilk
2015-09-16 15:14 ` Julien Grall [this message]
2015-09-16 16:18   ` Konrad Rzeszutek Wilk
  -- strict thread matches above, loose matches on Subject: below --
2015-09-16 17:12 Konrad Rzeszutek Wilk
2015-09-16 19:05 ` Andrew Cooper

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=55F98753.8020205@citrix.com \
    --to=julien.grall@citrix.com \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=konrad.wilk@oracle.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.