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.
--- xen/xsm/flask/ss/policydb.c | 2 ++ 1 file changed, 2 insertions(+)
xen/xsm/flask/ss/policydb.c +2 -0
@@ -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. */ 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. */ len =le32_to_cpu (buf[0 ]); usrdatum->value =le32_to_cpu (buf[1 ]);if ( p->policyvers >=POLICYDB_VERSION_BOUNDARY )
Signature · 7 lines
2.4.3 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Hi Konrad,
Quoted 8 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
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.
Quoted 14 lines
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]>--- xen/xsm/flask/ss/policydb.c | 2 ++ 1 file changed, 2 insertions(+)xen/xsm/flask/ss/policydb.c +0
-0
xen/xsm/flask/ss/policydb.c static int role_read(struct policydb *p, struct hashtab *h, void *fp) · line 1277
Quoted 4 lines
xen/xsm/flask/ss/policydb.c +1
-0@@ -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.
xen/xsm/flask/ss/policydb.c static int user_read(struct policydb *p, struct hashtab *h, void *fp) · line 1441
Quoted 8 lines
xen/xsm/flask/ss/policydb.c +1
-0len =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.
xen/xsm/flask/ss/policydb.c static int user_read(struct policydb *p, struct hashtab *h, void *fp) · line 1444
Quoted 4 lines
xen/xsm/flask/ss/policydb.c +0
-0len =le32_to_cpu (buf[0 ]); usrdatum->value =le32_to_cpu (buf[1 ]);if ( p->policyvers >=POLICYDB_VERSION_BOUNDARY )
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 44 lines · Julien Grall
Hi Konrad,
Quoted 8 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
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.Quoted 14 lines
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]>--- xen/xsm/flask/ss/policydb.c | 2 ++ 1 file changed, 2 insertions(+)xen/xsm/flask/ss/policydb.c +0
-0xen/xsm/flask/ss/policydb.c static int role_read(struct policydb *p, struct hashtab *h, void *fp) · line 1277
Quoted 4 lines
xen/xsm/flask/ss/policydb.c +1
-0@@ -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.Quoted 7 lines
xen/xsm/flask/ss/policydb.c +0
-0len =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;
Quoted 3 lines
xen/xsm/flask/ss/policydb.c static int user_read(struct policydb *p, struct hashtab *h, void *fp) · line 1441
Quoted 1 line
xen/xsm/flask/ss/policydb.c +1
-0+ buf[2 ] =0 ;/* To shut up compiler warnings. */ Ditto.
Duh! I had it in a differente location in the earlier patch and then moved down to make it after the 'goto bad'.
Thanks!
Quoted 10 lines
xen/xsm/flask/ss/policydb.c static int user_read(struct policydb *p, struct hashtab *h, void *fp) · line 1444
Quoted 5 lines
xen/xsm/flask/ss/policydb.c +0
-0len =le32_to_cpu (buf[0 ]); usrdatum->value =le32_to_cpu (buf[1 ]);if ( p->policyvers >=POLICYDB_VERSION_BOUNDARY )Regards,
Signature · 1 line
Julien Grall
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel