Skip to contentSkip to conversation

mcstrans: Fix Werror=shadow errors

PATCH In review Jason Zaman 2 participants 8 messages Nov 16, 2016 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 mcstrans: Fix Werror=shadow errors

gcc -g3 -O0 -gdwarf-2 -fno-strict-aliasing -Wall -Wshadow -Werror -I../include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIE -c -o mcstrans.o mcstrans.c mcstrans.c: In function ‘violates_constraints’:
mcstrans.c:551:14: error: declaration of ‘common’ shadows a previous local [-Werror=shadow]

    ebitmap_t common;
              ^
mcstrans.c:545:13: error: shadowed declaration is here [-Werror=shadow]
   ebitmap_t common;
             ^
mcstrans.c: In function ‘build_regexps’:
mcstrans.c:1048:7: error: declaration of ‘i’ shadows a previous local [-Werror=shadow]
   int i=0;
       ^
mcstrans.c:993:15: error: shadowed declaration is here [-Werror=shadow]
  size_t n_el, i;
               ^
mcstrans.c: In function ‘compute_raw_from_trans’:
mcstrans.c:1166:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c:1174:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c:1189:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c: In function ‘compute_trans_from_raw’:
mcstrans.c:1328:14: error: declaration of ‘unhandled’ shadows a previous local [-Werror=shadow]
    ebitmap_t unhandled, orig_unhandled;
              ^
mcstrans.c:1291:49: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                                 ^
mcstrans.c:1328:25: error: declaration of ‘orig_unhandled’ shadows a previous local [-Werror=shadow]
    ebitmap_t unhandled, orig_unhandled;
                         ^
mcstrans.c:1291:60: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                                            ^
mcstrans.c:1360:15: error: declaration of ‘handled’ shadows a previous local [-Werror=shadow]
     ebitmap_t handled, nothandled;
               ^
mcstrans.c:1291:28: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                            ^
mcstrans.c:1360:24: error: declaration of ‘nothandled’ shadows a previous local [-Werror=shadow]
     ebitmap_t handled, nothandled;
                        ^
mcstrans.c:1291:37: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                     ^
mcstrans.c:1377:17: error: declaration of ‘temp’ shadows a previous local [-Werror=shadow]
       ebitmap_t temp;
                 ^
mcstrans.c:1291:22: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                      ^
mcstrans.c:1378:17: error: declaration of ‘bit_diff’ shadows a previous local [-Werror=shadow]
       ebitmap_t bit_diff;
                 ^
mcstrans.c:1291:12: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
            ^
mcstrans.c:1403:16: error: declaration of ‘bit_diff’ shadows a previous local [-Werror=shadow]
      ebitmap_t bit_diff;
                ^
mcstrans.c:1291:12: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
            ^
mcstrans.c:1407:16: error: declaration of ‘temp’ shadows a previous local [-Werror=shadow]
      ebitmap_t temp;
                ^
mcstrans.c:1291:22: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                      ^
mcstrans.c:1434:19: error: declaration of ‘g’ shadows a previous local [-Werror=shadow]
     word_group_t *g;
                   ^
mcstrans.c:1335:18: error: shadowed declaration is here [-Werror=shadow]
    word_group_t *g;
                  ^

cc1: all warnings being treated as errors Makefile:35: recipe for target 'mcstrans.o' failed make[2]: *** [mcstrans.o] Error 1

---
 mcstrans/src/mcstrans.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
mcstrans/src/mcstrans.c +8 -16
index d7f094a..1b77d16 100644
@@ -525,9 +525,9 @@ int
 violates_constraints(mls_level_t *l) {
 	int nbits;
 	sens_constraint_t *s;
+	ebitmap_t common;
 	for (s=sens_constraints; s; s=s->next) {
 		if (s->sens == l->sens) {
-			ebitmap_t common;
 			if (ebitmap_and(&common, &s->cat, &l->cat) < 0)
 				return 1;
 			nbits = ebitmap_cardinality(&common);
@@ -542,13 +542,11 @@ violates_constraints(mls_level_t *l) {
 	}
 	cat_constraint_t *c;
 	for (c=cat_constraints; c; c=c->next) {
-		ebitmap_t common;
 		if (ebitmap_and(&common, &c->mask, &l->cat) < 0)
 			return 1;
 		nbits = ebitmap_cardinality(&common);
 		ebitmap_destroy(&common);
 		if (nbits > 0) {
-			ebitmap_t common;
 			if (ebitmap_and(&common, &c->cat, &l->cat) < 0)
 				return 1;
 			nbits = ebitmap_cardinality(&common);
@@ -1045,7 +1043,7 @@ build_regexps(domain_t *domain) {
 			return -1;
 		}
 
-		int i=0;
+		i=0;
 		for (w = g->words; w; w = w->next)
 			g->sword[i++]=w;
 
@@ -1094,6 +1092,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 	gettimeofday(&startTime, 0);
 #endif
 
+	int rc = 0;
 	int ovector[OVECCOUNT];
 	word_group_t *g = NULL;
 	char *work = NULL;
@@ -1120,7 +1119,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 	if (!domain->base_classification_regexp)
 		goto err;
 	log_debug(" compute_raw_from_trans work = %s\n", work);
-	int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
+	rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
 	if (rc > 0) {
 		match = NULL;
 		pcre_get_substring(work, ovector, rc, 0, &match);
@@ -1163,7 +1162,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 			int prefix_offset = 0, prefix_len = 0;
 			int suffix_offset = 0, suffix_len = 0;
 			if (g->prefix_regexp) {
-				int rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
+				rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
 				if (rc > 0) {
 					prefix = 1;
 					prefix_offset = ovector[0];
@@ -1171,7 +1170,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 				}
 			}
 			if (g->suffix_regexp) {
-				int rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
+				rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
 				if (rc > 0) {
 					suffix = 1;
 					suffix_offset = ovector[0];
@@ -1186,7 +1185,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 			     g->word_regexp) {
 				char *s = work + prefix_offset + prefix_len;
 				int l = (suffix_len ? suffix_offset : work_len) - prefix_len - prefix_offset;
-				int rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
+				rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
 				if (rc > 0) {
 					match = NULL;
 					pcre_get_substring(s, ovector, rc, 0, &match);
@@ -1285,6 +1284,7 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 	gettimeofday(&startTime, 0);
 #endif
 
+	word_group_t *g;
 	mls_level_t *l = NULL;
 	char *rval = NULL;
 	word_group_t *groups = NULL;
@@ -1325,14 +1325,12 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 				continue;
 
 			/* compute bits not consumed by base classification */
-			ebitmap_t unhandled, orig_unhandled;
 			if (ebitmap_xor(&unhandled, &l->cat, &bc->level->cat) < 0)
 				goto err;
 			if (ebitmap_cpy(&orig_unhandled, &unhandled) < 0)
 				goto err;
 
 			/* prebuild groups */
-			word_group_t *g;
 			for (g = domain->groups; g; g = g->next) {
 				word_group_t **t;
 				for (t = &groups; *t; t = &(*t)->next)
@@ -1357,7 +1355,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 			for (loops = 50; ebitmap_cardinality(&unhandled) && loops > 0 && change; loops--) {
 				change = 0;
 				hamming = 10000;
-				ebitmap_t handled, nothandled;
 				if (ebitmap_xor(&handled, &unhandled, &orig_unhandled) < 0)
 					goto err;
 				if (ebitmap_not(&nothandled, &handled, maxbit) < 0)
@@ -1374,8 +1371,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 						}
 
 						/* if only unhandled bits are different */
-						ebitmap_t temp;
-						ebitmap_t bit_diff;
 						if (ebitmap_or(&temp, &w->normal, &w->inverse) < 0)
 							goto err;
 						if (ebitmap_and(&bit_diff, &temp, &nothandled) < 0)
@@ -1400,11 +1395,9 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 				ebitmap_destroy(&nothandled);
 
 				if (currentWord) {
-					ebitmap_t bit_diff;
 					if (ebitmap_xor(&bit_diff, &currentWord->cat, &bc->level->cat) < 0)
 						goto err;
 
-					ebitmap_t temp;
 					if (ebitmap_cpy(&temp, &unhandled) < 0)
 						goto err;
 					ebitmap_destroy(&unhandled);
@@ -1431,7 +1424,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 				buffer[0] = 0;
 				strcat(buffer, bc->trans);
 				strcat(buffer, " ");
-				word_group_t *g;
 				for (g=groups; g; g = g->next) {
 					if (g->words && g->prefixes) {
 						strcat(buffer, g->prefixes->text);
Signature · 1 line
2.7.3
#1 lore raw

PATCH 2/5 mcstrans: take LIBDIR from args, dont guess

All the other makefiles just have LIBDIR optionally set so it can be overridden. These makefiles were autodetecting incorrectly. uname -i returns "GenuineIntel" so should have been uname -m.

---
 mcstrans/src/Makefile   | 18 ++----------------
 mcstrans/utils/Makefile | 18 +-----------------
 2 files changed, 3 insertions(+), 33 deletions(-)
mcstrans/src/Makefile +2 -16
index 907a1f1..ae74a16 100644
@@ -1,20 +1,6 @@
-ARCH = $(shell uname -i)
-ifeq "$(ARCH)" "x86_64"
-	# In case of 64 bit system, use these lines
-	LIBDIR=/usr/lib64
-else 
-ifeq "$(ARCH)" "i686"
-	# In case of 32 bit system, use these lines
-	LIBDIR=/usr/lib
-else
-ifeq "$(ARCH)" "i386"
-	# In case of 32 bit system, use these lines
-	LIBDIR=/usr/lib
-endif
-endif
-endif
 # Installation directories.
-PREFIX  ?= $(DESTDIR)/usr
+PREFIX ?= $(DESTDIR)/usr
+LIBDIR ?= $(PREFIX)/lib
 SBINDIR ?= $(DESTDIR)/sbin
 INITDIR ?= $(DESTDIR)/etc/rc.d/init.d
 SYSTEMDDIR ?= $(DESTDIR)/usr/lib/systemd
mcstrans/utils/Makefile +1 -17
index 1ffb027..43608db 100644
@@ -1,24 +1,8 @@
 # Installation directories.
 PREFIX ?= $(DESTDIR)/usr
+LIBDIR ?= $(PREFIX)/lib
 BINDIR ?= $(PREFIX)/sbin
 
-ARCH = $(shell uname -i)
-ifeq "$(ARCH)" "x86_64"
-        # In case of 64 bit system, use these lines
-        LIBDIR=/usr/lib64
-else
-ifeq "$(ARCH)" "i686"
-        # In case of 32 bit system, use these lines
-        LIBDIR=/usr/lib
-else
-ifeq "$(ARCH)" "i386"
-        # In case of 32 bit system, use these lines
-        LIBDIR=/usr/lib
-endif
-endif
-endif
-
-
 CFLAGS ?= -Wall
 override CFLAGS += -I../src -D_GNU_SOURCE
 LDLIBS += -L../src ../src/mcstrans.o ../src/mls_level.o -lselinux -lpcre $(LIBDIR)/libsepol.a
Signature · 1 line
2.7.3
#2 lore raw

PATCH 3/5 Add stub make test targets to new subdirs

In reply to Jason Zaman
---
 dbus/Makefile        | 2 ++
 gui/Makefile         | 2 ++
 mcstrans/Makefile    | 2 ++
 restorecond/Makefile | 1 +
 4 files changed, 7 insertions(+)
dbus/Makefile +2 -0
index c924052..9a6cc90 100644
@@ -13,3 +13,5 @@ install:
 	install -m 755 selinux_server.py $(DESTDIR)/usr/share/system-config-selinux
 
 relabel:
+
+test:
gui/Makefile +2 -0
index 4170e94..d49a7ce 100644
@@ -54,3 +54,5 @@ clean:
 indent:
 
 relabel:
+
+test:
mcstrans/Makefile +2 -0
index eb3d955..c993a9f 100644
@@ -14,3 +14,5 @@ clean:
 	$(MAKE) -C man clean
 
 relabel:
+
+test:
restorecond/Makefile +1 -0
index 02b7011..9f163f5 100644
@@ -60,3 +60,4 @@ clean:
 indent:
 	../../scripts/Lindent $(wildcard *.[ch])
 
+test:
Signature · 1 line
2.7.3
#3 lore raw

PATCH 4/5 mcstrans: Add utils gitignore

In reply to Jason Zaman
---
 mcstrans/utils/.gitignore | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 mcstrans/utils/.gitignore
mcstrans/utils/.gitignore new file +2 -0
new file mode 100644
index 0000000..5c6ee0b
@@ -0,0 +1,2 @@
+transcon
+untranscon
Signature · 1 line
2.7.3
#4 lore raw

PATCH 5/5 restorecond: Add gitignore

In reply to Jason Zaman
---
 .gitignore             | 2 +-
 restorecond/.gitignore | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 restorecond/.gitignore
.gitignore +1 -1
index 265cd23..6ff6126 100644
@@ -18,10 +18,10 @@
 *.orig
 *.rej
 *.pyc
+*.pyo
 cscope.*
 .#*
 \#*
 .*.swp
 # Failsafes
 !.gitignore
-restorecond/restorecond
restorecond/.gitignore new file +1 -0
new file mode 100644
index 0000000..f128429
@@ -0,0 +1 @@
+restorecond
Signature · 1 line
2.7.3
#5 lore raw
In reply to Jason Zaman

This whole series applies on top of the splitpolicycoreutils branch.

Quoted 243 lines · Jason Zaman

gcc -g3 -O0 -gdwarf-2 -fno-strict-aliasing -Wall -Wshadow -Werror -I../include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIE -c -o mcstrans.o mcstrans.c mcstrans.c: In function ‘violates_constraints’:
mcstrans.c:551:14: error: declaration of ‘common’ shadows a previous local [-Werror=shadow]

    ebitmap_t common;
              ^
mcstrans.c:545:13: error: shadowed declaration is here [-Werror=shadow]
   ebitmap_t common;
             ^
mcstrans.c: In function ‘build_regexps’:
mcstrans.c:1048:7: error: declaration of ‘i’ shadows a previous local [-Werror=shadow]
   int i=0;
       ^
mcstrans.c:993:15: error: shadowed declaration is here [-Werror=shadow]
  size_t n_el, i;
               ^
mcstrans.c: In function ‘compute_raw_from_trans’:
mcstrans.c:1166:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c:1174:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c:1189:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c: In function ‘compute_trans_from_raw’:
mcstrans.c:1328:14: error: declaration of ‘unhandled’ shadows a previous local [-Werror=shadow]
    ebitmap_t unhandled, orig_unhandled;
              ^
mcstrans.c:1291:49: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                                 ^
mcstrans.c:1328:25: error: declaration of ‘orig_unhandled’ shadows a previous local [-Werror=shadow]
    ebitmap_t unhandled, orig_unhandled;
                         ^
mcstrans.c:1291:60: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                                            ^
mcstrans.c:1360:15: error: declaration of ‘handled’ shadows a previous local [-Werror=shadow]
     ebitmap_t handled, nothandled;
               ^
mcstrans.c:1291:28: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                            ^
mcstrans.c:1360:24: error: declaration of ‘nothandled’ shadows a previous local [-Werror=shadow]
     ebitmap_t handled, nothandled;
                        ^
mcstrans.c:1291:37: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                     ^
mcstrans.c:1377:17: error: declaration of ‘temp’ shadows a previous local [-Werror=shadow]
       ebitmap_t temp;
                 ^
mcstrans.c:1291:22: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                      ^
mcstrans.c:1378:17: error: declaration of ‘bit_diff’ shadows a previous local [-Werror=shadow]
       ebitmap_t bit_diff;
                 ^
mcstrans.c:1291:12: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
            ^
mcstrans.c:1403:16: error: declaration of ‘bit_diff’ shadows a previous local [-Werror=shadow]
      ebitmap_t bit_diff;
                ^
mcstrans.c:1291:12: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
            ^
mcstrans.c:1407:16: error: declaration of ‘temp’ shadows a previous local [-Werror=shadow]
      ebitmap_t temp;
                ^
mcstrans.c:1291:22: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                      ^
mcstrans.c:1434:19: error: declaration of ‘g’ shadows a previous local [-Werror=shadow]
     word_group_t *g;
                   ^
mcstrans.c:1335:18: error: shadowed declaration is here [-Werror=shadow]
    word_group_t *g;
                  ^

cc1: all warnings being treated as errors Makefile:35: recipe for target 'mcstrans.o' failed make[2]: *** [mcstrans.o] Error 1

---
 mcstrans/src/mcstrans.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
mcstrans/src/mcstrans.c +8 -16
index d7f094a..1b77d16 100644
@@ -525,9 +525,9 @@ int
 violates_constraints(mls_level_t *l) {
 	int nbits;
 	sens_constraint_t *s;
+	ebitmap_t common;
 	for (s=sens_constraints; s; s=s->next) {
 		if (s->sens == l->sens) {
-			ebitmap_t common;
 			if (ebitmap_and(&common, &s->cat, &l->cat) < 0)
 				return 1;
 			nbits = ebitmap_cardinality(&common);
@@ -542,13 +542,11 @@ violates_constraints(mls_level_t *l) {
 	}
 	cat_constraint_t *c;
 	for (c=cat_constraints; c; c=c->next) {
-		ebitmap_t common;
 		if (ebitmap_and(&common, &c->mask, &l->cat) < 0)
 			return 1;
 		nbits = ebitmap_cardinality(&common);
 		ebitmap_destroy(&common);
 		if (nbits > 0) {
-			ebitmap_t common;
 			if (ebitmap_and(&common, &c->cat, &l->cat) < 0)
 				return 1;
 			nbits = ebitmap_cardinality(&common);
@@ -1045,7 +1043,7 @@ build_regexps(domain_t *domain) {
 			return -1;
 		}
 
-		int i=0;
+		i=0;
 		for (w = g->words; w; w = w->next)
 			g->sword[i++]=w;
 
@@ -1094,6 +1092,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 	gettimeofday(&startTime, 0);
 #endif
 
+	int rc = 0;
 	int ovector[OVECCOUNT];
 	word_group_t *g = NULL;
 	char *work = NULL;
@@ -1120,7 +1119,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 	if (!domain->base_classification_regexp)
 		goto err;
 	log_debug(" compute_raw_from_trans work = %s\n", work);
-	int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
+	rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
 	if (rc > 0) {
 		match = NULL;
 		pcre_get_substring(work, ovector, rc, 0, &match);
@@ -1163,7 +1162,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 			int prefix_offset = 0, prefix_len = 0;
 			int suffix_offset = 0, suffix_len = 0;
 			if (g->prefix_regexp) {
-				int rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
+				rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
 				if (rc > 0) {
 					prefix = 1;
 					prefix_offset = ovector[0];
@@ -1171,7 +1170,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 				}
 			}
 			if (g->suffix_regexp) {
-				int rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
+				rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
 				if (rc > 0) {
 					suffix = 1;
 					suffix_offset = ovector[0];
@@ -1186,7 +1185,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 			     g->word_regexp) {
 				char *s = work + prefix_offset + prefix_len;
 				int l = (suffix_len ? suffix_offset : work_len) - prefix_len - prefix_offset;
-				int rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
+				rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
 				if (rc > 0) {
 					match = NULL;
 					pcre_get_substring(s, ovector, rc, 0, &match);
@@ -1285,6 +1284,7 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 	gettimeofday(&startTime, 0);
 #endif
 
+	word_group_t *g;
 	mls_level_t *l = NULL;
 	char *rval = NULL;
 	word_group_t *groups = NULL;
@@ -1325,14 +1325,12 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 				continue;
 
 			/* compute bits not consumed by base classification */
-			ebitmap_t unhandled, orig_unhandled;
 			if (ebitmap_xor(&unhandled, &l->cat, &bc->level->cat) < 0)
 				goto err;
 			if (ebitmap_cpy(&orig_unhandled, &unhandled) < 0)
 				goto err;
 
 			/* prebuild groups */
-			word_group_t *g;
 			for (g = domain->groups; g; g = g->next) {
 				word_group_t **t;
 				for (t = &groups; *t; t = &(*t)->next)
@@ -1357,7 +1355,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 			for (loops = 50; ebitmap_cardinality(&unhandled) && loops > 0 && change; loops--) {
 				change = 0;
 				hamming = 10000;
-				ebitmap_t handled, nothandled;
 				if (ebitmap_xor(&handled, &unhandled, &orig_unhandled) < 0)
 					goto err;
 				if (ebitmap_not(&nothandled, &handled, maxbit) < 0)
@@ -1374,8 +1371,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 						}
 
 						/* if only unhandled bits are different */
-						ebitmap_t temp;
-						ebitmap_t bit_diff;
 						if (ebitmap_or(&temp, &w->normal, &w->inverse) < 0)
 							goto err;
 						if (ebitmap_and(&bit_diff, &temp, &nothandled) < 0)
@@ -1400,11 +1395,9 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 				ebitmap_destroy(&nothandled);
 
 				if (currentWord) {
-					ebitmap_t bit_diff;
 					if (ebitmap_xor(&bit_diff, &currentWord->cat, &bc->level->cat) < 0)
 						goto err;
 
-					ebitmap_t temp;
 					if (ebitmap_cpy(&temp, &unhandled) < 0)
 						goto err;
 					ebitmap_destroy(&unhandled);
@@ -1431,7 +1424,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 				buffer[0] = 0;
 				strcat(buffer, bc->trans);
 				strcat(buffer, " ");
-				word_group_t *g;
 				for (g=groups; g; g = g->next) {
 					if (g->words && g->prefixes) {
 						strcat(buffer, g->prefixes->text);
Signature · 1 line
2.7.3
#6 lore raw
Quoted 1 line · Jason Zaman

This whole series applies on top of the splitpolicycoreutils branch.

Thanks, applied on that branch (+ re-based again).
This reminds me that I need to figure out what to do about ChangeLogs for the new subdirs split from policycoreutils. mcstrans has an old one from when it was originally a separate, external project, that is obviously out of date and stale. The others don't have one at all. Options:
1) Update the mcstrans ChangeLog with any mcstrans changes since it was merged to policycoreutils and then keep on updating it. Create new ChangeLogs for the new subdirs and initially populate them from the relevant entries from the policycoreutils ChangeLog, at least for changes since 2.6.
or
2) Drop the ChangeLogs altogether and just let people use git to generate changelogs between releases.

Quoted 251 lines · Jason Zaman
Quoted 243 lines

gcc -g3 -O0 -gdwarf-2 -fno-strict-aliasing -Wall -Wshadow -Werror -I../include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIE -c -o mcstrans.o mcstrans.c mcstrans.c: In function ‘violates_constraints’:
mcstrans.c:551:14: error: declaration of ‘common’ shadows a previous local [-Werror=shadow]

    ebitmap_t common;
              ^
mcstrans.c:545:13: error: shadowed declaration is here [-Werror=shadow]
   ebitmap_t common;
             ^
mcstrans.c: In function ‘build_regexps’:
mcstrans.c:1048:7: error: declaration of ‘i’ shadows a previous local [-Werror=shadow]
   int i=0;
       ^
mcstrans.c:993:15: error: shadowed declaration is here [-Werror=shadow]
  size_t n_el, i;
               ^
mcstrans.c: In function ‘compute_raw_from_trans’:
mcstrans.c:1166:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c:1174:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c:1189:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c: In function ‘compute_trans_from_raw’:
mcstrans.c:1328:14: error: declaration of ‘unhandled’ shadows a previous local [-Werror=shadow]
    ebitmap_t unhandled, orig_unhandled;
              ^
mcstrans.c:1291:49: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                                 ^
mcstrans.c:1328:25: error: declaration of ‘orig_unhandled’ shadows a previous local [-Werror=shadow]
    ebitmap_t unhandled, orig_unhandled;
                         ^
mcstrans.c:1291:60: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                                            ^
mcstrans.c:1360:15: error: declaration of ‘handled’ shadows a previous local [-Werror=shadow]
     ebitmap_t handled, nothandled;
               ^
mcstrans.c:1291:28: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                            ^
mcstrans.c:1360:24: error: declaration of ‘nothandled’ shadows a previous local [-Werror=shadow]
     ebitmap_t handled, nothandled;
                        ^
mcstrans.c:1291:37: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                     ^
mcstrans.c:1377:17: error: declaration of ‘temp’ shadows a previous local [-Werror=shadow]
       ebitmap_t temp;
                 ^
mcstrans.c:1291:22: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                      ^
mcstrans.c:1378:17: error: declaration of ‘bit_diff’ shadows a previous local [-Werror=shadow]
       ebitmap_t bit_diff;
                 ^
mcstrans.c:1291:12: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
            ^
mcstrans.c:1403:16: error: declaration of ‘bit_diff’ shadows a previous local [-Werror=shadow]
      ebitmap_t bit_diff;
                ^
mcstrans.c:1291:12: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
            ^
mcstrans.c:1407:16: error: declaration of ‘temp’ shadows a previous local [-Werror=shadow]
      ebitmap_t temp;
                ^
mcstrans.c:1291:22: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                      ^
mcstrans.c:1434:19: error: declaration of ‘g’ shadows a previous local [-Werror=shadow]
     word_group_t *g;
                   ^
mcstrans.c:1335:18: error: shadowed declaration is here [-Werror=shadow]
    word_group_t *g;
                  ^

cc1: all warnings being treated as errors Makefile:35: recipe for target 'mcstrans.o' failed make[2]: *** [mcstrans.o] Error 1

---
 mcstrans/src/mcstrans.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
mcstrans/src/mcstrans.c +8 -16
index d7f094a..1b77d16 100644
@@ -525,9 +525,9 @@ int
 violates_constraints(mls_level_t *l) {
 	int nbits;
 	sens_constraint_t *s;
+	ebitmap_t common;
 	for (s=sens_constraints; s; s=s->next) {
 		if (s->sens == l->sens) {
-			ebitmap_t common;
 			if (ebitmap_and(&common, &s->cat, &l->cat) < 0)
 				return 1;
 			nbits = ebitmap_cardinality(&common);
@@ -542,13 +542,11 @@ violates_constraints(mls_level_t *l) {
 	}
 	cat_constraint_t *c;
 	for (c=cat_constraints; c; c=c->next) {
-		ebitmap_t common;
 		if (ebitmap_and(&common, &c->mask, &l->cat) < 0)
 			return 1;
 		nbits = ebitmap_cardinality(&common);
 		ebitmap_destroy(&common);
 		if (nbits > 0) {
-			ebitmap_t common;
 			if (ebitmap_and(&common, &c->cat, &l->cat) < 0)
 				return 1;
 			nbits = ebitmap_cardinality(&common);
@@ -1045,7 +1043,7 @@ build_regexps(domain_t *domain) {
 			return -1;
 		}
 
-		int i=0;
+		i=0;
 		for (w = g->words; w; w = w->next)
 			g->sword[i++]=w;
 
@@ -1094,6 +1092,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 	gettimeofday(&startTime, 0);
 #endif
 
+	int rc = 0;
 	int ovector[OVECCOUNT];
 	word_group_t *g = NULL;
 	char *work = NULL;
@@ -1120,7 +1119,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 	if (!domain->base_classification_regexp)
 		goto err;
 	log_debug(" compute_raw_from_trans work = %s\n", work);
-	int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
+	rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
 	if (rc > 0) {
 		match = NULL;
 		pcre_get_substring(work, ovector, rc, 0, &match);
@@ -1163,7 +1162,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 			int prefix_offset = 0, prefix_len = 0;
 			int suffix_offset = 0, suffix_len = 0;
 			if (g->prefix_regexp) {
-				int rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
+				rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
 				if (rc > 0) {
 					prefix = 1;
 					prefix_offset = ovector[0];
@@ -1171,7 +1170,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 				}
 			}
 			if (g->suffix_regexp) {
-				int rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
+				rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
 				if (rc > 0) {
 					suffix = 1;
 					suffix_offset = ovector[0];
@@ -1186,7 +1185,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 			     g->word_regexp) {
 				char *s = work + prefix_offset + prefix_len;
 				int l = (suffix_len ? suffix_offset : work_len) - prefix_len - prefix_offset;
-				int rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
+				rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
 				if (rc > 0) {
 					match = NULL;
 					pcre_get_substring(s, ovector, rc, 0, &match);
@@ -1285,6 +1284,7 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 	gettimeofday(&startTime, 0);
 #endif
 
+	word_group_t *g;
 	mls_level_t *l = NULL;
 	char *rval = NULL;
 	word_group_t *groups = NULL;
@@ -1325,14 +1325,12 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 				continue;
 
 			/* compute bits not consumed by base classification */
-			ebitmap_t unhandled, orig_unhandled;
 			if (ebitmap_xor(&unhandled, &l->cat, &bc->level->cat) < 0)
 				goto err;
 			if (ebitmap_cpy(&orig_unhandled, &unhandled) < 0)
 				goto err;
 
 			/* prebuild groups */
-			word_group_t *g;
 			for (g = domain->groups; g; g = g->next) {
 				word_group_t **t;
 				for (t = &groups; *t; t = &(*t)->next)
@@ -1357,7 +1355,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 			for (loops = 50; ebitmap_cardinality(&unhandled) && loops > 0 && change; loops--) {
 				change = 0;
 				hamming = 10000;
-				ebitmap_t handled, nothandled;
 				if (ebitmap_xor(&handled, &unhandled, &orig_unhandled) < 0)
 					goto err;
 				if (ebitmap_not(&nothandled, &handled, maxbit) < 0)
@@ -1374,8 +1371,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 						}
 
 						/* if only unhandled bits are different */
-						ebitmap_t temp;
-						ebitmap_t bit_diff;
 						if (ebitmap_or(&temp, &w->normal, &w->inverse) < 0)
 							goto err;
 						if (ebitmap_and(&bit_diff, &temp, &nothandled) < 0)
@@ -1400,11 +1395,9 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 				ebitmap_destroy(&nothandled);
 
 				if (currentWord) {
-					ebitmap_t bit_diff;
 					if (ebitmap_xor(&bit_diff, &currentWord->cat, &bc->level->cat) < 0)
 						goto err;
 
-					ebitmap_t temp;
 					if (ebitmap_cpy(&temp, &unhandled) < 0)
 						goto err;
 					ebitmap_destroy(&unhandled);
@@ -1431,7 +1424,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 				buffer[0] = 0;
 				strcat(buffer, bc->trans);
 				strcat(buffer, " ");
-				word_group_t *g;
 				for (g=groups; g; g = g->next) {
 					if (g->words && g->prefixes) {
 						strcat(buffer, g->prefixes->text);
Signature · 1 line
2.7.3

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

#7 lore raw
Quoted 17 lines · Stephen Smalley
Quoted 1 line · Jason Zaman

This whole series applies on top of the splitpolicycoreutils branch.

Thanks, applied on that branch (+ re-based again).
This reminds me that I need to figure out what to do about ChangeLogs for the new subdirs split from policycoreutils. mcstrans has an old one from when it was originally a separate, external project, that is obviously out of date and stale. The others don't have one at all. Options:
1) Update the mcstrans ChangeLog with any mcstrans changes since it was merged to policycoreutils and then keep on updating it. Create new ChangeLogs for the new subdirs and initially populate them from the relevant entries from the policycoreutils ChangeLog, at least for changes since 2.6.
or
2) Drop the ChangeLogs altogether and just let people use git to generate changelogs between releases.

The new subdirs can just start from scratch with a note to refer to policycoreutils for earlier stuff. mcstrans could just have a note about the missing gap.

I'm in favour of dropping them completely tho. Or if you really want them, only update the changelogs from git only right before releases. Having a second commit after every other one repeating the same commit msg seems wasteful.

Something like: git log --pretty=format:'%s <%an>' > ChangeLog

-- Jason

Quoted 252 lines
Quoted 251 lines · Jason Zaman
Quoted 243 lines

gcc -g3 -O0 -gdwarf-2 -fno-strict-aliasing -Wall -Wshadow -Werror -I../include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIE -c -o mcstrans.o mcstrans.c mcstrans.c: In function ‘violates_constraints’:
mcstrans.c:551:14: error: declaration of ‘common’ shadows a previous local [-Werror=shadow]

    ebitmap_t common;
              ^
mcstrans.c:545:13: error: shadowed declaration is here [-Werror=shadow]
   ebitmap_t common;
             ^
mcstrans.c: In function ‘build_regexps’:
mcstrans.c:1048:7: error: declaration of ‘i’ shadows a previous local [-Werror=shadow]
   int i=0;
       ^
mcstrans.c:993:15: error: shadowed declaration is here [-Werror=shadow]
  size_t n_el, i;
               ^
mcstrans.c: In function ‘compute_raw_from_trans’:
mcstrans.c:1166:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c:1174:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c:1189:9: error: declaration of ‘rc’ shadows a previous local [-Werror=shadow]
     int rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
         ^
mcstrans.c:1123:6: error: shadowed declaration is here [-Werror=shadow]
  int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
      ^
mcstrans.c: In function ‘compute_trans_from_raw’:
mcstrans.c:1328:14: error: declaration of ‘unhandled’ shadows a previous local [-Werror=shadow]
    ebitmap_t unhandled, orig_unhandled;
              ^
mcstrans.c:1291:49: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                                 ^
mcstrans.c:1328:25: error: declaration of ‘orig_unhandled’ shadows a previous local [-Werror=shadow]
    ebitmap_t unhandled, orig_unhandled;
                         ^
mcstrans.c:1291:60: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                                            ^
mcstrans.c:1360:15: error: declaration of ‘handled’ shadows a previous local [-Werror=shadow]
     ebitmap_t handled, nothandled;
               ^
mcstrans.c:1291:28: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                            ^
mcstrans.c:1360:24: error: declaration of ‘nothandled’ shadows a previous local [-Werror=shadow]
     ebitmap_t handled, nothandled;
                        ^
mcstrans.c:1291:37: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                                     ^
mcstrans.c:1377:17: error: declaration of ‘temp’ shadows a previous local [-Werror=shadow]
       ebitmap_t temp;
                 ^
mcstrans.c:1291:22: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                      ^
mcstrans.c:1378:17: error: declaration of ‘bit_diff’ shadows a previous local [-Werror=shadow]
       ebitmap_t bit_diff;
                 ^
mcstrans.c:1291:12: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
            ^
mcstrans.c:1403:16: error: declaration of ‘bit_diff’ shadows a previous local [-Werror=shadow]
      ebitmap_t bit_diff;
                ^
mcstrans.c:1291:12: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
            ^
mcstrans.c:1407:16: error: declaration of ‘temp’ shadows a previous local [-Werror=shadow]
      ebitmap_t temp;
                ^
mcstrans.c:1291:22: error: shadowed declaration is here [-Werror=shadow]
  ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
                      ^
mcstrans.c:1434:19: error: declaration of ‘g’ shadows a previous local [-Werror=shadow]
     word_group_t *g;
                   ^
mcstrans.c:1335:18: error: shadowed declaration is here [-Werror=shadow]
    word_group_t *g;
                  ^

cc1: all warnings being treated as errors Makefile:35: recipe for target 'mcstrans.o' failed make[2]: *** [mcstrans.o] Error 1

---
 mcstrans/src/mcstrans.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
mcstrans/src/mcstrans.c +8 -16
index d7f094a..1b77d16 100644
@@ -525,9 +525,9 @@ int
 violates_constraints(mls_level_t *l) {
 	int nbits;
 	sens_constraint_t *s;
+	ebitmap_t common;
 	for (s=sens_constraints; s; s=s->next) {
 		if (s->sens == l->sens) {
-			ebitmap_t common;
 			if (ebitmap_and(&common, &s->cat, &l->cat) < 0)
 				return 1;
 			nbits = ebitmap_cardinality(&common);
@@ -542,13 +542,11 @@ violates_constraints(mls_level_t *l) {
 	}
 	cat_constraint_t *c;
 	for (c=cat_constraints; c; c=c->next) {
-		ebitmap_t common;
 		if (ebitmap_and(&common, &c->mask, &l->cat) < 0)
 			return 1;
 		nbits = ebitmap_cardinality(&common);
 		ebitmap_destroy(&common);
 		if (nbits > 0) {
-			ebitmap_t common;
 			if (ebitmap_and(&common, &c->cat, &l->cat) < 0)
 				return 1;
 			nbits = ebitmap_cardinality(&common);
@@ -1045,7 +1043,7 @@ build_regexps(domain_t *domain) {
 			return -1;
 		}
 
-		int i=0;
+		i=0;
 		for (w = g->words; w; w = w->next)
 			g->sword[i++]=w;
 
@@ -1094,6 +1092,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 	gettimeofday(&startTime, 0);
 #endif
 
+	int rc = 0;
 	int ovector[OVECCOUNT];
 	word_group_t *g = NULL;
 	char *work = NULL;
@@ -1120,7 +1119,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 	if (!domain->base_classification_regexp)
 		goto err;
 	log_debug(" compute_raw_from_trans work = %s\n", work);
-	int rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
+	rc = pcre_exec(domain->base_classification_regexp, 0, work, work_len, 0, PCRE_ANCHORED, ovector, OVECCOUNT);
 	if (rc > 0) {
 		match = NULL;
 		pcre_get_substring(work, ovector, rc, 0, &match);
@@ -1163,7 +1162,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 			int prefix_offset = 0, prefix_len = 0;
 			int suffix_offset = 0, suffix_len = 0;
 			if (g->prefix_regexp) {
-				int rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
+				rc = pcre_exec(g->prefix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
 				if (rc > 0) {
 					prefix = 1;
 					prefix_offset = ovector[0];
@@ -1171,7 +1170,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 				}
 			}
 			if (g->suffix_regexp) {
-				int rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
+				rc = pcre_exec(g->suffix_regexp, 0, work, work_len, 0, 0, ovector, OVECCOUNT);
 				if (rc > 0) {
 					suffix = 1;
 					suffix_offset = ovector[0];
@@ -1186,7 +1185,7 @@ compute_raw_from_trans(const char *level, domain_t *domain) {
 			     g->word_regexp) {
 				char *s = work + prefix_offset + prefix_len;
 				int l = (suffix_len ? suffix_offset : work_len) - prefix_len - prefix_offset;
-				int rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
+				rc = pcre_exec(g->word_regexp, 0, s, l, 0, 0, ovector, OVECCOUNT);
 				if (rc > 0) {
 					match = NULL;
 					pcre_get_substring(s, ovector, rc, 0, &match);
@@ -1285,6 +1284,7 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 	gettimeofday(&startTime, 0);
 #endif
 
+	word_group_t *g;
 	mls_level_t *l = NULL;
 	char *rval = NULL;
 	word_group_t *groups = NULL;
@@ -1325,14 +1325,12 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 				continue;
 
 			/* compute bits not consumed by base classification */
-			ebitmap_t unhandled, orig_unhandled;
 			if (ebitmap_xor(&unhandled, &l->cat, &bc->level->cat) < 0)
 				goto err;
 			if (ebitmap_cpy(&orig_unhandled, &unhandled) < 0)
 				goto err;
 
 			/* prebuild groups */
-			word_group_t *g;
 			for (g = domain->groups; g; g = g->next) {
 				word_group_t **t;
 				for (t = &groups; *t; t = &(*t)->next)
@@ -1357,7 +1355,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 			for (loops = 50; ebitmap_cardinality(&unhandled) && loops > 0 && change; loops--) {
 				change = 0;
 				hamming = 10000;
-				ebitmap_t handled, nothandled;
 				if (ebitmap_xor(&handled, &unhandled, &orig_unhandled) < 0)
 					goto err;
 				if (ebitmap_not(&nothandled, &handled, maxbit) < 0)
@@ -1374,8 +1371,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 						}
 
 						/* if only unhandled bits are different */
-						ebitmap_t temp;
-						ebitmap_t bit_diff;
 						if (ebitmap_or(&temp, &w->normal, &w->inverse) < 0)
 							goto err;
 						if (ebitmap_and(&bit_diff, &temp, &nothandled) < 0)
@@ -1400,11 +1395,9 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 				ebitmap_destroy(&nothandled);
 
 				if (currentWord) {
-					ebitmap_t bit_diff;
 					if (ebitmap_xor(&bit_diff, &currentWord->cat, &bc->level->cat) < 0)
 						goto err;
 
-					ebitmap_t temp;
 					if (ebitmap_cpy(&temp, &unhandled) < 0)
 						goto err;
 					ebitmap_destroy(&unhandled);
@@ -1431,7 +1424,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
 				buffer[0] = 0;
 				strcat(buffer, bc->trans);
 				strcat(buffer, " ");
-				word_group_t *g;
 				for (g=groups; g; g = g->next) {
 					if (g->words && g->prefixes) {
 						strcat(buffer, g->prefixes->text);
Signature · 1 line
2.7.3

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].