Skip to contentSkip to conversation

libsepol write.c has shadowed var

PATCH In review Joshua Brindle 2 participants 4 messages Jun 13, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol write.c has shadowed var

This patch addresses a shadowed var that prevents libsepol from being built with DEBUG=1

---

src/write.c +3 -3
Index: libsepol/src/write.c
===================================================================
@@ -1625,10 +1625,10 @@
 	if (p->policyvers < POLICYDB_VERSION_PERMISSIVE &&
 	    p->policy_type == POLICY_KERN) {
 		ebitmap_node_t *tnode;
-		unsigned int i;
+		unsigned int j;
 
-		ebitmap_for_each_bit(&p->permissive_map, tnode, i) {
-			if (ebitmap_node_get_bit(tnode, i)) {
+		ebitmap_for_each_bit(&p->permissive_map, tnode, j) {
+			if (ebitmap_node_get_bit(tnode, j)) {
 				WARN(fp->handle, "Warning! Policy version %d cannot "
 				     "support permissive types, but some were defined",
 				     p->policyvers);

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 14 lines · Joshua Brindle

This patch addresses a shadowed var that prevents libsepol from being built with DEBUG=1

---

Index: libsepol/src/write.c
===================================================================

src/write.c +0 -0
@@ -1625,10 +1625,10 @@
 	if (p->policyvers < POLICYDB_VERSION_PERMISSIVE &&
 	    p->policy_type == POLICY_KERN) {
 		ebitmap_node_t *tnode;

src/write.c line 1634

Quoted 10 lines
src/write.c +3 -3
-		unsigned int i;
+		unsigned int j;
 
-		ebitmap_for_each_bit(&p->permissive_map, tnode, i) {
-			if (ebitmap_node_get_bit(tnode, i)) {
+		ebitmap_for_each_bit(&p->permissive_map, tnode, j) {
+			if (ebitmap_node_get_bit(tnode, j)) {
 				WARN(fp->handle, "Warning! Policy version %d cannot "
 				     "support permissive types, but some were defined",
 				     p->policyvers);

Any particular reason we can't just use the local var from the outer scope?

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 18 lines · Stephen Smalley
Quoted 17 lines · Joshua Brindle

This patch addresses a shadowed var that prevents libsepol from being built with DEBUG=1

---

Index: libsepol/src/write.c
===================================================================

src/write.c +1 -1
@@ -1625,10 +1625,10 @@
 	if (p->policyvers < POLICYDB_VERSION_PERMISSIVE &&
 	    p->policy_type == POLICY_KERN) {
 		ebitmap_node_t *tnode;
-		unsigned int i;
+		unsigned int j;
 
Quoted 11 lines

src/write.c line 1634

Quoted 7 lines
src/write.c +2 -2
-		ebitmap_for_each_bit(&p->permissive_map, tnode, i) {
-			if (ebitmap_node_get_bit(tnode, i)) {
+		ebitmap_for_each_bit(&p->permissive_map, tnode, j) {
+			if (ebitmap_node_get_bit(tnode, j)) {
 				WARN(fp->handle, "Warning! Policy version %d cannot "
 				     "support permissive types, but some were defined",
 				     p->policyvers);

Any particular reason we can't just use the local var from the outer scope?

good point, I didn't really look at how i was being used. This uses i from the outer scope and adds -Wshadow to library and checkpolicy makefiles.

---

src/Makefile +1 -1
Index: libsemanage/src/Makefile
===================================================================
@@ -31,7 +31,7 @@
 LIBSO=$(TARGET).$(LIBVERSION)
 OBJS= $(patsubst %.c,%.o,$(filter-out $(SWIGCOUT),$(wildcard *.c))) conf-scan.o conf-parse.o
 LOBJS= $(patsubst %.c,%.lo,$(filter-out $(SWIGCOUT),$(wildcard *.c))) conf-scan.lo conf-parse.lo
-CFLAGS ?= -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute -Wno-unused-parameter
+CFLAGS ?= -Wall -W -Wundef -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wno-unused-parameter
 
 override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE 
 
src/Makefile +1 -1
Index: libsepol/src/Makefile
===================================================================
@@ -10,7 +10,7 @@
 LIBSO=$(TARGET).$(LIBVERSION)
 OBJS= $(patsubst %.c,%.o,$(wildcard *.c))
 LOBJS= $(patsubst %.c,%.lo,$(wildcard *.c))
-CFLAGS ?= -Werror -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute
+CFLAGS ?= -Werror -Wall -W -Wundef -Wshadow -Wmissing-noreturn -Wmissing-format-attribute
 override CFLAGS += -I. -I../include -D_GNU_SOURCE
 
 all: $(LIBA) $(LIBSO)
src/write.c +0 -1
Index: libsepol/src/write.c
===================================================================
@@ -1625,7 +1625,6 @@
 	if (p->policyvers < POLICYDB_VERSION_PERMISSIVE &&
 	    p->policy_type == POLICY_KERN) {
 		ebitmap_node_t *tnode;
-		unsigned int i;
 
 		ebitmap_for_each_bit(&p->permissive_map, tnode, i) {
 			if (ebitmap_node_get_bit(tnode, i)) {
Makefile +1 -1
Index: checkpolicy/Makefile
===================================================================
@@ -10,7 +10,7 @@
 
 YACC = bison -y
 
-CFLAGS ?= -g -Wall -Werror -O2 -pipe -fno-strict-aliasing
+CFLAGS ?= -g -Wall -Werror -Wshadow -O2 -pipe -fno-strict-aliasing
 
 override CFLAGS += -I. -I${INCLUDEDIR}
 
src/Makefile +1 -1
Index: libselinux/src/Makefile
===================================================================
@@ -33,7 +33,7 @@
 
 OBJS= $(patsubst %.c,%.o,$(SRCS))
 LOBJS= $(patsubst %.c,%.lo,$(SRCS))
-CFLAGS ?= -Werror -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute
+CFLAGS ?= -Werror -Wall -W -Wundef -Wshadow -Wmissing-noreturn -Wmissing-format-attribute
 override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(EMFLAGS)
 RANLIB=ranlib
 

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw
Quoted 92 lines · Joshua Brindle
Quoted 18 lines · Stephen Smalley
Quoted 17 lines · Joshua Brindle

This patch addresses a shadowed var that prevents libsepol from being built with DEBUG=1

---

Index: libsepol/src/write.c
===================================================================

src/write.c +1 -1
@@ -1625,10 +1625,10 @@
 	if (p->policyvers < POLICYDB_VERSION_PERMISSIVE &&
 	    p->policy_type == POLICY_KERN) {
 		ebitmap_node_t *tnode;
-		unsigned int i;
+		unsigned int j;
 
Quoted 11 lines

src/write.c line 1634

Quoted 7 lines
src/write.c +2 -2
-		ebitmap_for_each_bit(&p->permissive_map, tnode, i) {
-			if (ebitmap_node_get_bit(tnode, i)) {
+		ebitmap_for_each_bit(&p->permissive_map, tnode, j) {
+			if (ebitmap_node_get_bit(tnode, j)) {
 				WARN(fp->handle, "Warning! Policy version %d cannot "
 				     "support permissive types, but some were defined",
 				     p->policyvers);

Any particular reason we can't just use the local var from the outer scope?

good point, I didn't really look at how i was being used. This uses i from the outer scope and adds -Wshadow to library and checkpolicy makefiles.

---

Index: libsemanage/src/Makefile
===================================================================

src/Makefile +1 -1
@@ -31,7 +31,7 @@
 LIBSO=$(TARGET).$(LIBVERSION)
 OBJS= $(patsubst %.c,%.o,$(filter-out $(SWIGCOUT),$(wildcard *.c))) conf-scan.o conf-parse.o
 LOBJS= $(patsubst %.c,%.lo,$(filter-out $(SWIGCOUT),$(wildcard *.c))) conf-scan.lo conf-parse.lo
-CFLAGS ?= -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute -Wno-unused-parameter
+CFLAGS ?= -Wall -W -Wundef -Wshadow -Wmissing-noreturn -Wmissing-format-attribute -Wno-unused-parameter
 
 override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE 
 

Index: libsepol/src/Makefile
===================================================================

src/Makefile +1 -1
@@ -10,7 +10,7 @@
 LIBSO=$(TARGET).$(LIBVERSION)
 OBJS= $(patsubst %.c,%.o,$(wildcard *.c))
 LOBJS= $(patsubst %.c,%.lo,$(wildcard *.c))
-CFLAGS ?= -Werror -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute
+CFLAGS ?= -Werror -Wall -W -Wundef -Wshadow -Wmissing-noreturn -Wmissing-format-attribute
 override CFLAGS += -I. -I../include -D_GNU_SOURCE
 
 all: $(LIBA) $(LIBSO)

Index: libsepol/src/write.c
===================================================================

src/write.c +0 -1
@@ -1625,7 +1625,6 @@
 	if (p->policyvers < POLICYDB_VERSION_PERMISSIVE &&
 	    p->policy_type == POLICY_KERN) {
 		ebitmap_node_t *tnode;
-		unsigned int i;
 
 		ebitmap_for_each_bit(&p->permissive_map, tnode, i) {
 			if (ebitmap_node_get_bit(tnode, i)) {

Index: checkpolicy/Makefile
===================================================================

Makefile +1 -1
@@ -10,7 +10,7 @@
 
 YACC = bison -y
 
-CFLAGS ?= -g -Wall -Werror -O2 -pipe -fno-strict-aliasing
+CFLAGS ?= -g -Wall -Werror -Wshadow -O2 -pipe -fno-strict-aliasing
 
 override CFLAGS += -I. -I${INCLUDEDIR}
 

Index: libselinux/src/Makefile
===================================================================

src/Makefile line 38

Quoted 7 lines
src/Makefile +1 -1
@@ -33,7 +33,7 @@
 
 OBJS= $(patsubst %.c,%.o,$(SRCS))
 LOBJS= $(patsubst %.c,%.lo,$(SRCS))
-CFLAGS ?= -Werror -Wall -W -Wundef -Wmissing-noreturn -Wmissing-format-attribute
+CFLAGS ?= -Werror -Wall -W -Wundef -Wshadow -Wmissing-noreturn -Wmissing-format-attribute
 override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(EMFLAGS)
 RANLIB=ranlib

Merge at will.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.