Skip to contentSkip to conversation

kconfig: qconf: use if_changed for qconf.moc rule

PATCH New Masahiro Yamada 1 participant 3 messages Jul 29, 2020

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

PATCH v2 1/3 kconfig: qconf: use if_changed for qconf.moc rule

Regenerate qconf.moc when the moc command is changed.

This also allows 'make mrproper' to clean it up. Previously, it was not cleaned up because 'clean-files += qconf.moc' was missing. Now 'make mrproper' correctly cleans it up because files listed in 'targets' are cleaned.

---

Changes in v2:
- Use 'targets' instead of 'clean-files'

 scripts/kconfig/Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/kconfig/Makefile +4 -2
index 426881ea954f..a5e770e75653 100644
@@ -192,8 +192,10 @@ $(obj)/qconf.o: $(obj)/qconf-cfg $(obj)/qconf.moc
 quiet_cmd_moc = MOC     $@
       cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) -i $< -o $@
 
-$(obj)/%.moc: $(src)/%.h $(obj)/qconf-cfg
-	$(call cmd,moc)
+$(obj)/%.moc: $(src)/%.h $(obj)/qconf-cfg FORCE
+	$(call if_changed,moc)
+
+targets += qconf.moc
 
 # gconf: Used for the gconfig target based on GTK+
 hostprogs	+= gconf
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 2/3 kconfig: qconf: compile moc object separately

Currently, qconf.moc is included from qconf.cc but they can be compiled independently.

When you modify qconf.cc, qconf.moc does not need recompiling.

Rename qconf.moc to qconf.moc.cc, and split it out as an independent compilation unit.

---

Changes in v2:
- New patch

 scripts/kconfig/.gitignore |  2 +-
 scripts/kconfig/Makefile   | 11 ++++++-----
 scripts/kconfig/qconf.cc   |  1 -
 3 files changed, 7 insertions(+), 7 deletions(-)
scripts/kconfig/.gitignore +1 -1
index 12a67fdab541..5914a3f5408c 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-*.moc
+/qconf.moc.cc
 *conf-cfg
 
 #
scripts/kconfig/Makefile +6 -5
index a5e770e75653..96d015473288 100644
@@ -181,21 +181,22 @@ $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
 
 # qconf: Used for the xconfig target based on Qt
 hostprogs	+= qconf
-qconf-cxxobjs	:= qconf.o
+qconf-cxxobjs	:= qconf.o qconf.moc.o
 qconf-objs	:= images.o $(common-objs)
 
 HOSTLDLIBS_qconf	= $(shell . $(obj)/qconf-cfg && echo $$libs)
 HOSTCXXFLAGS_qconf.o	= $(shell . $(obj)/qconf-cfg && echo $$cflags)
+HOSTCXXFLAGS_qconf.moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
 
-$(obj)/qconf.o: $(obj)/qconf-cfg $(obj)/qconf.moc
+$(obj)/qconf.o: $(obj)/qconf-cfg
 
 quiet_cmd_moc = MOC     $@
-      cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) -i $< -o $@
+      cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@
 
-$(obj)/%.moc: $(src)/%.h $(obj)/qconf-cfg FORCE
+$(obj)/qconf.moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE
 	$(call if_changed,moc)
 
-targets += qconf.moc
+targets += qconf.moc.cc
 
 # gconf: Used for the gconfig target based on GTK+
 hostprogs	+= gconf
scripts/kconfig/qconf.cc +0 -1
index 4a616128a154..bb0a0bd511b9 100644
@@ -23,7 +23,6 @@
 #include "lkc.h"
 #include "qconf.h"
 
-#include "qconf.moc"
 #include "images.h"
 
 
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 3/3 kconfig: qconf: use delete[] instead of delete to free array

In reply to Masahiro Yamada

cppcheck reports "Mismatching allocation and deallocation".

$ cppcheck scripts/kconfig/qconf.cc
Checking scripts/kconfig/qconf.cc ...
scripts/kconfig/qconf.cc:1242:10: error: Mismatching allocation and deallocation: data [mismatchAllocDealloc]
  delete data;
         ^
scripts/kconfig/qconf.cc:1236:15: note: Mismatching allocation and deallocation: data
 char *data = new char[count + 1];
              ^
scripts/kconfig/qconf.cc:1242:10: note: Mismatching allocation and deallocation: data
  delete data;
         ^
scripts/kconfig/qconf.cc:1255:10: error: Mismatching allocation and deallocation: data [mismatchAllocDealloc]
  delete data;
         ^
scripts/kconfig/qconf.cc:1236:15: note: Mismatching allocation and deallocation: data
 char *data = new char[count + 1];
              ^
scripts/kconfig/qconf.cc:1255:10: note: Mismatching allocation and deallocation: data
  delete data;
         ^
Fixes c4f7398bee9c ("kconfig: qconf: make debug links work again")

---

Changes in v2:
- Remove the description about the remaining qconf.moc

 scripts/kconfig/qconf.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/kconfig/qconf.cc +2 -2
index bb0a0bd511b9..3a11940ff5dc 100644
@@ -1238,7 +1238,7 @@ void ConfigInfoView::clicked(const QUrl &url)
 
 	if (count < 1) {
 		qInfo() << "Clicked link is empty";
-		delete data;
+		delete[] data;
 		return;
 	}
 
@@ -1251,7 +1251,7 @@ void ConfigInfoView::clicked(const QUrl &url)
 	result = sym_re_search(data);
 	if (!result) {
 		qInfo() << "Clicked symbol is invalid:" << data;
-		delete data;
+		delete[] data;
 		return;
 	}
 
Signature · 1 line
2.25.1