git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 0/3] Enable more compiler warnings for devs

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Mar 29, 2018, 15:03 UTC
Message-ID
<20180329150322.10722-1-pclouds@gmail.com>
In-Reply-To
<20180324125348.6614-1-pclouds@gmail.com>

v3 fixes the fallthru warnings in connect.c, and with json-writer series rerolled, 'pu' should build cleanly now. -Wno-maybe-uninitialized is removed, thanks to Ramsay.

v3 also adds an experimental patch that adds EAGER_DEVELOPER=1. These developers will have all warnings enabled (nothing is suppressed) but they are not fatal. They could go through them and perhaps clean up the code base a bit more.

Interdiff
diff --git a/Makefile b/Makefile
index e6680a8977..e4f04ce1cb 100644
--- a/Makefile
+++ b/Makefile
@@ -434,7 +434,9 @@ all::
 #
 # Define DEVELOPER to enable more compiler warnings. Compiler version
 # and faimily are auto detected, but could be overridden by defining
-# COMPILER_FEATURES (see config.mak.dev)
+# COMPILER_FEATURES (see config.mak.dev).
+# Define EAGER_DEVELOPER keeps compiler warnings non-fatal, but no warning
+# class is suppressed anymore.
 
 GIT-VERSION-FILE: FORCE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1041,6 +1043,9 @@ include config.mak.uname
 -include config.mak.autogen
 -include config.mak
 
+ifdef EAGER_DEVELOPER
+DEVELOPER = Yes
+endif
 ifdef DEVELOPER
 include config.mak.dev
 endif
diff --git a/config.mak.dev b/config.mak.dev
index d8beaf9347..13883410b3 100644
--- a/config.mak.dev
+++ b/config.mak.dev
@@ -1,4 +1,6 @@
+ifndef EAGER_DEVELOPER
 CFLAGS += -Werror
+endif
 CFLAGS += -Wdeclaration-after-statement
 CFLAGS += -Wno-format-zero-length
 CFLAGS += -Wold-style-definition
@@ -18,13 +20,23 @@ endif
 
 ifneq ($(or $(filter gcc6,$(COMPILER_FEATURES)),$(filter clang4,$(COMPILER_FEATURES))),)
 CFLAGS += -Wextra
+# if a function is public, there should be a prototype and the right
+# header file should be included. If not, it should be static.
 CFLAGS += -Wmissing-prototypes
+ifndef EAGER_DEVELOPER
+# These are disabled because we have these all over the place.
 CFLAGS += -Wno-empty-body
 CFLAGS += -Wno-missing-field-initializers
 CFLAGS += -Wno-sign-compare
 CFLAGS += -Wno-unused-function
 CFLAGS += -Wno-unused-parameter
-ifneq ($(filter gcc6,$(COMPILER_FEATURES)),)
-CFLAGS += -Wno-maybe-uninitialized
+endif
+endif
+
+# uninitialized warnings on gcc 4.9.2 in xdiff/xdiffi.c and config.c
+# not worth fixing since newer compilers correctly stop complaining
+ifneq ($(filter gcc4,$(COMPILER_FEATURES)),)
+ifeq ($(filter gcc5,$(COMPILER_FEATURES)),)
+CFLAGS += -Wno-uninitialized
 endif
 endif
diff --git a/connect.c b/connect.c
index c3a014c5ba..49eca46462 100644
--- a/connect.c
+++ b/connect.c
@@ -46,7 +46,7 @@ int check_ref_type(const struct ref *ref, int flags)
 	return check_ref(ref->name, flags);
 }
 
-static void die_initial_contact(int unexpected)
+static NORETURN void die_initial_contact(int unexpected)
 {
 	if (unexpected)
 		die(_("The remote end hung up upon initial contact"));


Nguyễn Thái Ngọc Duy (3):
  connect.c: mark die_initial_contact() NORETURN
  Makefile: detect compiler and enable more warnings in DEVELOPER=1
  Makefile: add EAGER_DEVELOPER mode

 Makefile        | 20 +++++++++----------
 config.mak.dev  | 42 +++++++++++++++++++++++++++++++++++++++
 connect.c       |  2 +-
 detect-compiler | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 106 insertions(+), 11 deletions(-)
 create mode 100644 config.mak.dev
 create mode 100755 detect-compiler
-- 
2.17.0.rc1.439.gca064e2955
Previous: Junio C HamanoNext: Nguyễn Thái Ngọc Duy
Message 28 of 47 in “travis-ci: enable more warnings on travis linux-gcc job”
  1. travis-ci: enable more warnings on travis linux-gcc jobNguyễn Thái Ngọc Duy, Mar 3, 2018
  2. travis-ci: enable more warnings on travis linux-gcc jobNguyễn Thái Ngọc Duy, Mar 16, 2018
  3. Jeff KingMar 16, 2018
  4. Duy NguyenMar 17, 2018
  5. Lars SchneiderMar 17, 2018
  6. Duy NguyenMar 17, 2018
  7. Jeff KingMar 17, 2018
  8. Jeff KingMar 17, 2018
  9. Junio C HamanoMar 17, 2018
  10. Makefile: detect compiler and enable more warnings in DEVELOPER=1Nguyễn Thái Ngọc Duy, Mar 18, 2018
  11. Eric SunshineMar 18, 2018
  12. Duy NguyenMar 18, 2018
  13. Jeff KingMar 18, 2018
  14. Eric SunshineMar 18, 2018
  15. Jeff KingMar 18, 2018
  16. Eric SunshineMar 18, 2018
  17. Jeff KingMar 18, 2018
  18. Duy NguyenMar 18, 2018
  19. Duy NguyenMar 18, 2018
  20. Ramsay JonesMar 18, 2018
  21. Duy NguyenMar 19, 2018
  22. Jeff KingMar 20, 2018
  23. Makefile: detect compiler and enable more warnings in DEVELOPER=1Nguyễn Thái Ngọc Duy, Mar 24, 2018
  24. Eric SunshineMar 25, 2018
  25. Junio C HamanoMar 26, 2018
  26. Duy NguyenMar 27, 2018
  27. Junio C HamanoMar 27, 2018
  28. 0/3 Enable more compiler warnings for devsNguyễn Thái Ngọc Duy, Mar 29, 2018
  29. 3/3 Makefile: add EAGER_DEVELOPER modeNguyễn Thái Ngọc Duy, Mar 29, 2018
  30. 2/3 Makefile: detect compiler and enable more warnings in DEVELOPER=1Nguyễn Thái Ngọc Duy, Mar 29, 2018
  31. 1/3 connect.c: mark die_initial_contact() NORETURNNguyễn Thái Ngọc Duy, Mar 29, 2018
  32. 4/3 Makefile: untangle DEVELOPER and -WerrorÆvar Arnfjörð Bjarmason, Mar 31, 2018
  33. Duy NguyenMar 31, 2018
  34. Ævar Arnfjörð BjarmasonApr 3, 2018
  35. Duy NguyenApr 3, 2018
  36. Jeff KingApr 6, 2018
  37. Duy NguyenApr 7, 2018
  38. Ævar Arnfjörð BjarmasonApr 7, 2018
  39. Duy NguyenApr 7, 2018
  40. Ævar Arnfjörð BjarmasonApr 7, 2018
  41. 0/4 Make DEVELOPER more more flexible with DEVOPTSÆvar Arnfjörð Bjarmason, Apr 14, 2018
  42. 1/4 connect.c: mark die_initial_contact() NORETURNÆvar Arnfjörð Bjarmason, Apr 14, 2018
  43. 2/4 Makefile: detect compiler and enable more warnings in DEVELOPER=1Ævar Arnfjörð Bjarmason, Apr 14, 2018
  44. 3/4 Makefile: add a DEVOPTS to suppress -Werror under DEVELOPERÆvar Arnfjörð Bjarmason, Apr 14, 2018
  45. 4/4 Makefile: add a DEVOPTS to get all of -WextraÆvar Arnfjörð Bjarmason, Apr 14, 2018
  46. Junio C HamanoApr 16, 2018
  47. Jeff KingMar 17, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.