Skip to contentSkip to conversation

kconfig: remove unused variable in qconf.cc

PATCH In review Masahiro Yamada 2 participants 6 messages Mar 25, 2020 – Mar 29, 2020

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

PATCH 1/2 kconfig: remove unused variable in qconf.cc

If this file were compiled with -Wall, the following warning would be reported:

scripts/kconfig/qconf.cc:312:6: warning: unused variable ‘i’ [-Wunused-variable]

  int i;
      ^

The commit prepares to turn on -Wall for C++ host programs.

---

 scripts/kconfig/qconf.cc | 2 --
 1 file changed, 2 deletions(-)
scripts/kconfig/qconf.cc +0 -2
index 82773cc35d35..50a5245d87bb 100644
@@ -309,8 +309,6 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
 	  showName(false), showRange(false), showData(false), mode(singleMode), optMode(normalOpt),
 	  rootEntry(0), headerPopup(0)
 {
-	int i;
-
 	setObjectName(name);
 	setSortingEnabled(false);
 	setRootIsDecorated(true);
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/2 kbuild: add -Wall to KBUILD_HOSTCXXFLAGS

Add -Wall to catch more warnings for C++ host programs.

When I submitted the previous version, the 0-day bot reported -Wc++11-compat warnings for old GCC:

HOSTCXX -fPIC scripts/gcc-plugins/latent_entropy_plugin.o
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/tm.h:28:0,
from scripts/gcc-plugins/gcc-common.h:15,
from scripts/gcc-plugins/latent_entropy_plugin.c:78:
/usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/config/elfos.h:102:21: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]

    fprintf ((FILE), "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
                     ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/config/elfos.h:170:24: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]
       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",  \
                        ^

In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/tm.h:42:0,
from scripts/gcc-plugins/gcc-common.h:15,
from scripts/gcc-plugins/latent_entropy_plugin.c:78:
/usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/defaults.h:126:24: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]

       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",  \
                        ^

The source of the warnings is in the plugin headers, so we have no control of it. I just suppressed them by adding -Wno-c++11-compat to scripts/gcc-plugins/Makefile.

---

 Makefile                     | 2 +-
 scripts/gcc-plugins/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Makefile +1 -1
index 3b57ccab367b..593d8f1bbe90 100644
@@ -400,7 +400,7 @@ HOSTCXX      = g++
 KBUILD_HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
 		-fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
 		$(HOSTCFLAGS)
-KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
+KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
 KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
 KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
 
scripts/gcc-plugins/Makefile +1 -1
index f2ee8bd7abc6..efff00959a9c 100644
@@ -10,7 +10,7 @@ else
   HOSTLIBS := hostcxxlibs
   HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++98 -fno-rtti
   HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb
-  HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable
+  HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable -Wno-c++11-compat
   export HOST_EXTRACXXFLAGS
 endif
 
Signature · 1 line
2.17.1
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] kbuild: add -Wall to KBUILD_HOSTCXXFLAGS

Quoted 19 lines · Masahiro Yamada

Add -Wall to catch more warnings for C++ host programs.

When I submitted the previous version, the 0-day bot reported -Wc++11-compat warnings for old GCC:

HOSTCXX -fPIC scripts/gcc-plugins/latent_entropy_plugin.o
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/tm.h:28:0,
from scripts/gcc-plugins/gcc-common.h:15,
from scripts/gcc-plugins/latent_entropy_plugin.c:78:
/usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/config/elfos.h:102:21: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]

    fprintf ((FILE), "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
                     ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/config/elfos.h:170:24: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]
       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",  \
                        ^

In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/tm.h:42:0,
from scripts/gcc-plugins/gcc-common.h:15,
from scripts/gcc-plugins/latent_entropy_plugin.c:78:
/usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/defaults.h:126:24: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]

Quoted 8 lines
       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",  \
                        ^

The source of the warnings is in the plugin headers, so we have no control of it. I just suppressed them by adding -Wno-c++11-compat to scripts/gcc-plugins/Makefile.

-Kees

Quoted 35 lines

---

 Makefile                     | 2 +-
 scripts/gcc-plugins/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Makefile +1 -1
index 3b57ccab367b..593d8f1bbe90 100644
@@ -400,7 +400,7 @@ HOSTCXX      = g++
 KBUILD_HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
 		-fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
 		$(HOSTCFLAGS)
-KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
+KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
 KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
 KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
 
scripts/gcc-plugins/Makefile +1 -1
index f2ee8bd7abc6..efff00959a9c 100644
@@ -10,7 +10,7 @@ else
   HOSTLIBS := hostcxxlibs
   HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++98 -fno-rtti
   HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb
-  HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable
+  HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable -Wno-c++11-compat
   export HOST_EXTRACXXFLAGS
 endif
 
Signature · 1 line
2.17.1
Signature · 1 line
Kees Cook
#3 lore raw

Re: [PATCH 2/2] kbuild: add -Wall to KBUILD_HOSTCXXFLAGS

Quoted 28 lines · Kees Cook
Quoted 26 lines · Masahiro Yamada

Add -Wall to catch more warnings for C++ host programs.

When I submitted the previous version, the 0-day bot reported -Wc++11-compat warnings for old GCC:

HOSTCXX -fPIC scripts/gcc-plugins/latent_entropy_plugin.o
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/tm.h:28:0,
from scripts/gcc-plugins/gcc-common.h:15,
from scripts/gcc-plugins/latent_entropy_plugin.c:78:
/usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/config/elfos.h:102:21: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]

    fprintf ((FILE), "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
                     ^
/usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/config/elfos.h:170:24: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]
       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",  \
                        ^

In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/tm.h:42:0,
from scripts/gcc-plugins/gcc-common.h:15,
from scripts/gcc-plugins/latent_entropy_plugin.c:78:
/usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/defaults.h:126:24: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]

       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",  \
                        ^

The source of the warnings is in the plugin headers, so we have no control of it. I just suppressed them by adding -Wno-c++11-compat to scripts/gcc-plugins/Makefile.

Quoted 5 lines
Quoted 1 line

-Kees

Applied to linux-kbuild.

Signature · 2 lines
Best Regards
Masahiro Yamada
Reviewed-by on v1 1/2
#4 lore raw
In reply to Masahiro Yamada
Quoted 10 lines · Masahiro Yamada

If this file were compiled with -Wall, the following warning would be reported:

scripts/kconfig/qconf.cc:312:6: warning: unused variable ‘i’ [-Wunused-variable]

  int i;
      ^

The commit prepares to turn on -Wall for C++ host programs.

-Kees

Quoted 21 lines

---

 scripts/kconfig/qconf.cc | 2 --
 1 file changed, 2 deletions(-)
scripts/kconfig/qconf.cc +0 -2
index 82773cc35d35..50a5245d87bb 100644
@@ -309,8 +309,6 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
 	  showName(false), showRange(false), showData(false), mode(singleMode), optMode(normalOpt),
 	  rootEntry(0), headerPopup(0)
 {
-	int i;
-
 	setObjectName(name);
 	setSortingEnabled(false);
 	setRootIsDecorated(true);
Signature · 1 line
2.17.1
Signature · 1 line
Kees Cook
#5 lore raw
Quoted 9 lines · Kees Cook
Quoted 7 lines · Masahiro Yamada

If this file were compiled with -Wall, the following warning would be reported:

scripts/kconfig/qconf.cc:312:6: warning: unused variable ‘i’ [-Wunused-variable]

  int i;
      ^
Quoted 6 lines
Quoted 3 lines

The commit prepares to turn on -Wall for C++ host programs.

Applied to linux-kbuild.

Quoted 26 lines

-Kees

Quoted 19 lines

---

 scripts/kconfig/qconf.cc | 2 --
 1 file changed, 2 deletions(-)
scripts/kconfig/qconf.cc +0 -3
index 82773cc35d35..50a5245d87bb 100644
@@ -309,8 +309,6 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
        showName(false), showRange(false), showData(false), mode(singleMode), optMode(normalOpt),
        rootEntry(0), headerPopup(0)
 {
-     int i;
-
      setObjectName(name);
      setSortingEnabled(false);
      setRootIsDecorated(true);
--
Quoted 2 lines

2.17.1

--
Kees Cook

Signature · 2 lines
Best Regards
Masahiro Yamada