Skip to contentSkip to conversation

dtc: Enable more warnings

PATCH Applied David Gibson 2 participants 9 messages Mar 3, 2010 – Mar 10, 2010 2 messages not in the archive Kbuild

lore
Share & tools
lore
#0 lore raw

This patch turns on a bunch of extra gcc warnings, most of which are probably a good idea. Of the new warnings -Wnested-externs and -Wstrict-prototypes need no code changes, we're already warning-clean. The remaining one, -Wmissing-prototypes requires trivial changes in some of the tests (making functions local).

This patch also rearranges the warnings flags into a separate make variable for convenience, and turns on -Werror, to really encourage people to keep the code warning-clean.

Makefile +3 -1
Index: dtc/Makefile
===================================================================
@@ -16,7 +16,9 @@ LOCAL_VERSION =
 CONFIG_LOCALVERSION =
 
 CPPFLAGS = -I libfdt
-CFLAGS = -Wall -g -Os -fPIC -Wpointer-arith -Wcast-qual
+WARNINGS = -Werror -Wall  -Wpointer-arith -Wcast-qual -Wnested-externs \
+	-Wstrict-prototypes -Wmissing-prototypes
+CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
 
 CPPFLAGS += -std=c99 -D_XOPEN_SOURCE -D_BSD_SOURCE
 CFLAGS += -Werror
tests/extra-terminating-null.c +1 -1
Index: dtc/tests/extra-terminating-null.c
===================================================================
@@ -28,7 +28,7 @@
 #include "tests.h"
 #include "testdata.h"
 
-void check_extranull(void *fdt, const char *prop, const char *str, int numnulls)
+static void check_extranull(void *fdt, const char *prop, const char *str, int numnulls)
 {
 	int len = strlen(str);
 	char checkbuf[len+numnulls];
tests/get_alias.c +1 -1
Index: dtc/tests/get_alias.c
===================================================================
@@ -29,7 +29,7 @@
 #include "tests.h"
 #include "testdata.h"
 
-void check_alias(void *fdt, const char *path, const char *alias)
+static void check_alias(void *fdt, const char *path, const char *alias)
 {
 	const char *aliaspath;
 
tests/path_offset_aliases.c +1 -1
Index: dtc/tests/path_offset_aliases.c
===================================================================
@@ -29,7 +29,7 @@
 #include "tests.h"
 #include "testdata.h"
 
-void check_alias(void *fdt, const char *full_path, const char *alias_path)
+static void check_alias(void *fdt, const char *full_path, const char *alias_path)
 {
 	int offset, offset_a;
 
tests/value-labels.c +2 -2
Index: dtc/tests/value-labels.c
===================================================================
@@ -59,8 +59,8 @@ struct val_label labels3[] = {
 	{ "end3", -1 },
 };
 
-void check_prop_labels(void *sohandle, void *fdt, const char *name,
-		       const struct val_label* labels, int n)
+static void check_prop_labels(void *sohandle, void *fdt, const char *name,
+			      const struct val_label* labels, int n)
 {
 	const struct fdt_property *prop;
 	const char *p;
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#1 lore raw
Quoted 11 lines

This patch turns on a bunch of extra gcc warnings, most of which are probably a good idea. Of the new warnings -Wnested-externs and -Wstrict-prototypes need no code changes, we're already warning-clean. The remaining one, -Wmissing-prototypes requires trivial changes in some of the tests (making functions local).

This patch also rearranges the warnings flags into a separate make variable for convenience, and turns on -Werror, to really encourage people to keep the code warning-clean.

This patch didn't apply due to something wrong here:

Quoted 5 lines

Index: dtc/Makefile
===================================================================

Makefile LOCAL_VERSION = · line 24

Quoted 10 lines
Makefile +3 -1
@@ -16,7 +16,9 @@ LOCAL_VERSION =
 CONFIG_LOCALVERSION =
 
 CPPFLAGS = -I libfdt
-CFLAGS = -Wall -g -Os -fPIC -Wpointer-arith -Wcast-qual
+WARNINGS = -Werror -Wall  -Wpointer-arith -Wcast-qual -Wnested-externs \
+	-Wstrict-prototypes -Wmissing-prototypes
+CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
 
 CPPFLAGS += -std=c99 -D_XOPEN_SOURCE -D_BSD_SOURCE
 CFLAGS += -Werror

I think it is the extra CPPFLAGS line? I dont seem to have that.

Thanks,
jdl

#3 lore raw
In reply to a message not in the archive
Quoted 27 lines · Jon Loeliger
Quoted 11 lines

This patch turns on a bunch of extra gcc warnings, most of which are probably a good idea. Of the new warnings -Wnested-externs and -Wstrict-prototypes need no code changes, we're already warning-clean. The remaining one, -Wmissing-prototypes requires trivial changes in some of the tests (making functions local).

This patch also rearranges the warnings flags into a separate make variable for convenience, and turns on -Werror, to really encourage people to keep the code warning-clean.

This patch didn't apply due to something wrong here:

Quoted 13 lines

Index: dtc/Makefile
===================================================================

Makefile +3 -1
@@ -16,7 +16,9 @@ LOCAL_VERSION =
 CONFIG_LOCALVERSION =
 
 CPPFLAGS = -I libfdt
-CFLAGS = -Wall -g -Os -fPIC -Wpointer-arith -Wcast-qual
+WARNINGS = -Werror -Wall  -Wpointer-arith -Wcast-qual -Wnested-externs \
+	-Wstrict-prototypes -Wmissing-prototypes
+CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
 
Quoted 5 lines

Makefile LOCAL_VERSION = · line 24

Quoted 2 lines
Makefile +0 -0
 CPPFLAGS += -std=c99 -D_XOPEN_SOURCE -D_BSD_SOURCE
 CFLAGS += -Werror

I think it is the extra CPPFLAGS line? I dont seem to have that.

Drat, sorry. I forgot I had an extra patch interposed in my series. Resending.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#4 lore raw
In reply to David Gibson

This patch turns on a bunch of extra gcc warnings, most of which are probably a good idea. Of the new warnings -Wnested-externs and -Wstrict-prototypes need no code changes, we're already warning-clean. The remaining one, -Wmissing-prototypes requires trivial changes in some of the tests (making functions local).

This patch also rearranges the warnings flags into a separate make variable for convenience, and turns on -Werror, to really encourage people to keep the code warning-clean.

Makefile +3 -1
Index: dtc/Makefile
===================================================================
@@ -16,7 +16,9 @@ LOCAL_VERSION =
 CONFIG_LOCALVERSION =
 
 CPPFLAGS = -I libfdt
-CFLAGS = -Wall -g -Os -fPIC -Wpointer-arith -Wcast-qual
+WARNINGS = -Werror -Wall -Wextra -Wpointer-arith -Wcast-qual -Wnested-externs \
+	-Wstrict-prototypes -Wmissing-prototypes
+CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
 
 BISON = bison
 LEX = flex
tests/extra-terminating-null.c +1 -1
Index: dtc/tests/extra-terminating-null.c
===================================================================
@@ -28,7 +28,7 @@
 #include "tests.h"
 #include "testdata.h"
 
-void check_extranull(void *fdt, const char *prop, const char *str, int numnulls)
+static void check_extranull(void *fdt, const char *prop, const char *str, int numnulls)
 {
 	int len = strlen(str);
 	char checkbuf[len+numnulls];
tests/get_alias.c +1 -1
Index: dtc/tests/get_alias.c
===================================================================
@@ -29,7 +29,7 @@
 #include "tests.h"
 #include "testdata.h"
 
-void check_alias(void *fdt, const char *path, const char *alias)
+static void check_alias(void *fdt, const char *path, const char *alias)
 {
 	const char *aliaspath;
 
tests/path_offset_aliases.c +1 -1
Index: dtc/tests/path_offset_aliases.c
===================================================================
@@ -29,7 +29,7 @@
 #include "tests.h"
 #include "testdata.h"
 
-void check_alias(void *fdt, const char *full_path, const char *alias_path)
+static void check_alias(void *fdt, const char *full_path, const char *alias_path)
 {
 	int offset, offset_a;
 
tests/value-labels.c +2 -2
Index: dtc/tests/value-labels.c
===================================================================
@@ -59,8 +59,8 @@ struct val_label labels3[] = {
 	{ "end3", -1 },
 };
 
-void check_prop_labels(void *sohandle, void *fdt, const char *name,
-		       const struct val_label* labels, int n)
+static void check_prop_labels(void *sohandle, void *fdt, const char *name,
+			      const struct val_label* labels, int n)
 {
 	const struct fdt_property *prop;
 	const char *p;
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#5 lore raw
Quoted 11 lines

This patch turns on a bunch of extra gcc warnings, most of which are probably a good idea. Of the new warnings -Wnested-externs and -Wstrict-prototypes need no code changes, we're already warning-clean. The remaining one, -Wmissing-prototypes requires trivial changes in some of the tests (making functions local).

This patch also rearranges the warnings flags into a separate make variable for convenience, and turns on -Werror, to really encourage people to keep the code warning-clean.

Well, I'd like to apply this patch. Doing so is actually effective!

$ make check 2>&1 | less
        CHK version_gen.h
         CC tests/testutils.o
cc1: warnings being treated as errors
tests/testutils.c: In sigint_:
tests/testutils.c:44: error: unused 
tests/testutils.c:44: error: unused 
tests/testutils.c: In test_:
tests/testutils.c:52: error: unused 
tests/testutils.c: In check_:
tests/testutils.c:113: error: comparison between signed and unsigned
tests/testutils.c:117: error: comparison between signed and unsigned
make: *** [tests/testutils.o] Error 1
propertyfunction argcparameter initfunction ucparameter siparameter handlerfunction 
#6 lore raw
In reply to David Gibson
Quoted 11 lines

This patch turns on a bunch of extra gcc warnings, most of which are probably a good idea. Of the new warnings -Wnested-externs and -Wstrict-prototypes need no code changes, we're already warning-clean. The remaining one, -Wmissing-prototypes requires trivial changes in some of the tests (making functions local).

This patch also rearranges the warnings flags into a separate make variable for convenience, and turns on -Werror, to really encourage people to keep the code warning-clean.

Well, I'd like to apply this patch. But doing so appears to be very effective. So much so that the "make check" now fails:

$ gcc --version
gcc (Debian 4.3.2-1.1) 4.3.2
$ make check
	CHK version_gen.h
	 CC tests/testutils.o
cc1: warnings being treated as errors
tests/testutils.c: In function ‘sigint_handler’:
tests/testutils.c:44: error: unused parameter ‘si’
tests/testutils.c:44: error: unused parameter ‘uc’
tests/testutils.c: In function ‘test_init’:
tests/testutils.c:52: error: unused parameter ‘argc’
tests/testutils.c: In function ‘check_property’:
tests/testutils.c:113: error: comparison between signed and unsigned
tests/testutils.c:117: error: comparison between signed and unsigned
make: *** [tests/testutils.o] Error 1

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

#8 lore raw
In reply to a message not in the archive
Quoted 10 lines · Jon Loeliger
Quoted 10 lines

This patch turns on a bunch of extra gcc warnings, most of which are probably a good idea. Of the new warnings -Wnested-externs and -Wstrict-prototypes need no code changes, we're already warning-clean. The remaining one, -Wmissing-prototypes requires trivial changes in some of the tests (making functions local).

This patch also rearranges the warnings flags into a separate make variable for convenience, and turns on -Werror, to really encourage people to keep the code warning-clean.

Quoted 5 lines
Quoted 1 line

Well, I'd like to apply this patch. But doing so appears to be very effective. So much so that the "make check" now fails:

Ugh. That's the -Wextra. Somehow I managed to add the -Wextra and thought (to my surprise) that it didn't add any extra warnings over the ones we already had. I was wrong, obviously. I'm not sure quite how I managed to miss that. I'll resend.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#9 lore raw

This patch turns on a bunch of extra gcc warnings, most of which are probably a good idea. Of the new warnings -Wnested-externs and -Wstrict-prototypes need no code changes, we're already warning-clean. The remaining one, -Wmissing-prototypes requires trivial changes in some of the tests (making functions local).

This patch also rearranges the warnings flags into a separate make variable for convenience, and turns on -Werror, to really encourage people to keep the code warning-clean.

---

Third time lucky. Please?

Makefile +3 -1
Index: dtc/Makefile
===================================================================
@@ -16,7 +16,9 @@ LOCAL_VERSION =
 CONFIG_LOCALVERSION =
 
 CPPFLAGS = -I libfdt
-CFLAGS = -Wall -g -Os -fPIC -Wpointer-arith -Wcast-qual
+WARNINGS = -Werror -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
+	-Wstrict-prototypes -Wmissing-prototypes
+CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
 
 BISON = bison
 LEX = flex
tests/extra-terminating-null.c +1 -1
Index: dtc/tests/extra-terminating-null.c
===================================================================
@@ -28,7 +28,7 @@
 #include "tests.h"
 #include "testdata.h"
 
-void check_extranull(void *fdt, const char *prop, const char *str, int numnulls)
+static void check_extranull(void *fdt, const char *prop, const char *str, int numnulls)
 {
 	int len = strlen(str);
 	char checkbuf[len+numnulls];
tests/get_alias.c +1 -1
Index: dtc/tests/get_alias.c
===================================================================
@@ -29,7 +29,7 @@
 #include "tests.h"
 #include "testdata.h"
 
-void check_alias(void *fdt, const char *path, const char *alias)
+static void check_alias(void *fdt, const char *path, const char *alias)
 {
 	const char *aliaspath;
 
tests/path_offset_aliases.c +1 -1
Index: dtc/tests/path_offset_aliases.c
===================================================================
@@ -29,7 +29,7 @@
 #include "tests.h"
 #include "testdata.h"
 
-void check_alias(void *fdt, const char *full_path, const char *alias_path)
+static void check_alias(void *fdt, const char *full_path, const char *alias_path)
 {
 	int offset, offset_a;
 
tests/value-labels.c +2 -2
Index: dtc/tests/value-labels.c
===================================================================
@@ -59,8 +59,8 @@ struct val_label labels3[] = {
 	{ "end3", -1 },
 };
 
-void check_prop_labels(void *sohandle, void *fdt, const char *name,
-		       const struct val_label* labels, int n)
+static void check_prop_labels(void *sohandle, void *fdt, const char *name,
+			      const struct val_label* labels, int n)
 {
 	const struct fdt_property *prop;
 	const char *p;
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Applied
#10 lore raw
Quoted 10 lines

This patch turns on a bunch of extra gcc warnings, most of which are probably a good idea. Of the new warnings -Wnested-externs and -Wstrict-prototypes need no code changes, we're already warning-clean. The remaining one, -Wmissing-prototypes requires trivial changes in some of the tests (making functions local).

This patch also rearranges the warnings flags into a separate make variable for convenience, and turns on -Werror, to really encourage people to keep the code warning-clean.

Quoted 5 lines

---

Third time lucky. Please?

Applied!

jdl