xen/xsm: Shut up GCC 5.1.1 warnings.
PATCH 1/1 xen/xsm: Shut up GCC 5.1.1 warnings.
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]). 2). There are other instances of this which are not triggering this
failure.
But GCC insists, and this patch stops the failures.
---
v2: Wrong placement of the buf[2]=0;
--- xen/xsm/flask/ss/policydb.c | 2 ++ 1 file changed, 2 insertions(+)
xen/xsm/flask/ss/policydb.c +2 -0
@@ -1266,6 +1266,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp) goto out; } + buf[2 ] =0 ;/* To shut up compiler warnings. */ if ( p->policyvers >=POLICYDB_VERSION_BOUNDARY ) rc =next_entry (buf, fp,sizeof (buf[0 ]) *3 );else
@@ -1429,6 +1430,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp) goto out; } + buf[2 ] =0 ;/* To shut up compiler warnings. */ if ( p->policyvers >=POLICYDB_VERSION_BOUNDARY ) rc =next_entry (buf, fp,sizeof (buf[0 ]) *3 );else
Signature · 7 lines
2.4.3 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 6 lines · Konrad Rzeszutek Wilk
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
Quoted 8 lines
Which makes no sense, as :
1). A couple of lines above it is being filled (buf[2]). 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 <[email protected]>
A better bet would just be to initialise buf at declaration time, so "__le32 buf[3] = { 0 };"
The reason this warning is firing is that C may not assume that p->policyvers doesn't change between the next_entry() call and the role->bounds assignment. Pulling p->policyvers into a local variable might also be sufficient.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel