]> xenbits.xensource.com Git - xen.git/commitdiff
xen/xsm: Make p->policyvers be a local variable (ver) to shut up GCC 5.1.1 warnings.
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 8 Oct 2015 10:43:53 +0000 (12:43 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 8 Oct 2015 10:43:53 +0000 (12:43 +0200)
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: 6a2f81459e1455d65a9a6f78dd2a0d0278619680
master date: 2015-09-22 12:09:03 -0400

xen/xsm/flask/ss/policydb.c

index bdec4ac264e73fcb2335a6a3da1208d5f38aec61..32ea1c33f5353c7189e0fb46848ab41789397d94 100644 (file)
@@ -1225,6 +1225,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 = xmalloc(struct role_datum);
     if ( !role )
@@ -1234,7 +1235,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp)
     }
     memset(role, 0, sizeof(*role));
 
-    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);
@@ -1244,7 +1245,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);
@@ -1296,6 +1297,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 = xmalloc(struct type_datum);
     if ( !typdatum )
@@ -1305,7 +1307,7 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp)
     }
     memset(typdatum, 0, sizeof(*typdatum));
 
-    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);
@@ -1315,7 +1317,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]);
 
@@ -1390,6 +1392,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 = xmalloc(struct user_datum);
     if ( !usrdatum )
@@ -1399,7 +1402,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp)
     }
     memset(usrdatum, 0, sizeof(*usrdatum));
 
-    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);
@@ -1409,7 +1412,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);
@@ -1427,7 +1430,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 )