mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
xen/xsm: Make p->policyvers be a local variable (ver) to 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 (as Andrew mentioned) is because GCC cannot assume
that 'p->policyvers' has the same value between checks.
We make it local, optimize the name to 'ver' and the warnings go away.
We also update another call site with this modification to
make it more inline with the rest of the functions.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
master commit: 6a2f81459e
master date: 2015-09-22 12:09:03 -0400
This commit is contained in:
1 parent
0297baf5b5
commit
d3d476f505
1 file changed
+10
-7
@@ -1219,6 +1219,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp)
|
||||
int rc;
|
||||
__le32 buf[3];
|
||||
u32 len;
|
||||
u32 ver = p->policyvers;
|
||||
|
||||
role = xzalloc(struct role_datum);
|
||||
if ( !role )
|
||||
@@ -1227,7 +1228,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
|
||||
if ( ver >= POLICYDB_VERSION_BOUNDARY )
|
||||
rc = next_entry(buf, fp, sizeof(buf[0]) * 3);
|
||||
else
|
||||
rc = next_entry(buf, fp, sizeof(buf[0]) * 2);
|
||||
@@ -1237,7 +1238,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp)
|
||||
|
||||
len = le32_to_cpu(buf[0]);
|
||||
role->value = le32_to_cpu(buf[1]);
|
||||
if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
|
||||
if ( ver >= POLICYDB_VERSION_BOUNDARY )
|
||||
role->bounds = le32_to_cpu(buf[2]);
|
||||
|
||||
key = xmalloc_array(char, len + 1);
|
||||
@@ -1289,6 +1290,7 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp)
|
||||
int rc;
|
||||
__le32 buf[4];
|
||||
u32 len;
|
||||
u32 ver = p->policyvers;
|
||||
|
||||
typdatum = xzalloc(struct type_datum);
|
||||
if ( !typdatum )
|
||||
@@ -1297,7 +1299,7 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp)
|
||||
return rc;
|
||||
}
|
||||
|
||||
if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
|
||||
if ( ver >= POLICYDB_VERSION_BOUNDARY )
|
||||
rc = next_entry(buf, fp, sizeof(buf[0]) * 4);
|
||||
else
|
||||
rc = next_entry(buf, fp, sizeof(buf[0]) * 3);
|
||||
@@ -1307,7 +1309,7 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp)
|
||||
|
||||
len = le32_to_cpu(buf[0]);
|
||||
typdatum->value = le32_to_cpu(buf[1]);
|
||||
if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
|
||||
if ( ver >= POLICYDB_VERSION_BOUNDARY )
|
||||
{
|
||||
u32 prop = le32_to_cpu(buf[2]);
|
||||
|
||||
@@ -1382,6 +1384,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp)
|
||||
int rc;
|
||||
__le32 buf[3];
|
||||
u32 len;
|
||||
u32 ver = p->policyvers;
|
||||
|
||||
usrdatum = xzalloc(struct user_datum);
|
||||
if ( !usrdatum )
|
||||
@@ -1390,7 +1393,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
|
||||
if ( ver >= POLICYDB_VERSION_BOUNDARY )
|
||||
rc = next_entry(buf, fp, sizeof(buf[0]) * 3);
|
||||
else
|
||||
rc = next_entry(buf, fp, sizeof(buf[0]) * 2);
|
||||
@@ -1400,7 +1403,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp)
|
||||
|
||||
len = le32_to_cpu(buf[0]);
|
||||
usrdatum->value = le32_to_cpu(buf[1]);
|
||||
if ( p->policyvers >= POLICYDB_VERSION_BOUNDARY )
|
||||
if ( ver >= POLICYDB_VERSION_BOUNDARY )
|
||||
usrdatum->bounds = le32_to_cpu(buf[2]);
|
||||
|
||||
key = xmalloc_array(char, len + 1);
|
||||
@@ -1418,7 +1421,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp)
|
||||
if ( rc )
|
||||
goto bad;
|
||||
|
||||
if ( p->policyvers >= POLICYDB_VERSION_MLS )
|
||||
if ( ver >= POLICYDB_VERSION_MLS )
|
||||
{
|
||||
rc = mls_read_range_helper(&usrdatum->range, fp);
|
||||
if ( rc )
|
||||
|
||||