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

Re: [Xen-devel] [PATCH] xen/xsm: Shut up GCC 5.1.1 warnings.



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@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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