diff mbox series

[5/7] kconfig: qconf: use nullptr in C++11 code

Message ID 2286001.iZASKD2KPV@devpool47.emlix.com (mailing list archive)
State New
Headers show
Series improve qconfig C++ code | expand

Commit Message

Rolf Eike Beer Oct. 23, 2024, 6:34 a.m. UTC
This is type safe as it can't be accidentially assigned to something not a
pointer.

Signed-off-by: Rolf Eike Beer <eb@emlix.com>
---
 scripts/kconfig/qconf.cc | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Masahiro Yamada Oct. 23, 2024, 4:41 p.m. UTC | #1
On Wed, Oct 23, 2024 at 3:35 PM Rolf Eike Beer <eb@emlix.com> wrote:
>
> This is type safe as it can't be accidentially assigned to something not a
> pointer.

This is incomplete because there are more call sites that use
0 instead of nullptr.

For example, you can replace nextItem(0) with nextItem(nullptr)

Anyway, I do not need this patch for now because qconf is
under refactoring, and I will remove a lot of code.

Please come back with a more comprehensive patch
some months later if you are still interested.





--
Best Regards
Masahiro Yamada
Rolf Eike Beer Oct. 24, 2024, 7:05 a.m. UTC | #2
On Mittwoch, 23. Oktober 2024 18:41:09 Mitteleuropäische Sommerzeit Masahiro 
Yamada wrote:
> On Wed, Oct 23, 2024 at 3:35 PM Rolf Eike Beer <eb@emlix.com> wrote:
> > This is type safe as it can't be accidentially assigned to something not a
> > pointer.
> 
> This is incomplete because there are more call sites that use
> 0 instead of nullptr.
> 
> For example, you can replace nextItem(0) with nextItem(nullptr)
> 
> Anyway, I do not need this patch for now because qconf is
> under refactoring, and I will remove a lot of code.
> 
> Please come back with a more comprehensive patch
> some months later if you are still interested.

This was just some obvious cases I came accross, nothing complete. If you are 
going to touch code anyway I personally would recommend using nullptr whenever 
you touch that things anyway and maybe someone can clean up the rest later. 
But this is nothing that does any change in behavior, so I'm fine with dropping 
it.

Regards,

Eike
diff mbox series

Patch

diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 313a51941825..563ef8543d7c 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -874,7 +874,7 @@  skip:
 
 void ConfigList::focusInEvent(QFocusEvent *e)
 {
-	struct menu *menu = NULL;
+	struct menu *menu = nullptr;
 
 	Parent::focusInEvent(e);
 
@@ -933,7 +933,7 @@  void ConfigList::setAllOpen(bool open)
 }
 
 ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
-	: Parent(parent), sym(0), _menu(0)
+	: Parent(parent), sym(nullptr), _menu(nullptr)
 {
 	setObjectName(name);
 	setOpenLinks(false);
@@ -985,7 +985,7 @@  void ConfigInfoView::setInfo(struct menu *m)
 	if (_menu == m)
 		return;
 	_menu = m;
-	sym = NULL;
+	sym = nullptr;
 	if (!_menu)
 		clear();
 	else
@@ -1167,7 +1167,7 @@  void ConfigInfoView::clicked(const QUrl &url)
 {
 	QByteArray str = url.toEncoded();
 	struct symbol **result;
-	struct menu *m = NULL;
+	struct menu *m = nullptr;
 
 	if (str.isEmpty())
 		return;
@@ -1208,7 +1208,7 @@  void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)
 }
 
 ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow *parent)
-	: Parent(parent), result(NULL)
+	: Parent(parent), result(nullptr)
 {
 	setObjectName("search");
 	setWindowTitle("Search Config");
@@ -1281,7 +1281,7 @@  void ConfigSearchWindow::search(void)
 {
 	struct symbol **p;
 	struct property *prop;
-	ConfigItem *lastItem = NULL;
+	ConfigItem *lastItem = nullptr;
 
 	free(result);
 	list->clear();
@@ -1580,7 +1580,7 @@  void ConfigMainWindow::changeMenu(struct menu *menu)
 void ConfigMainWindow::setMenuLink(struct menu *menu)
 {
 	struct menu *parent;
-	ConfigList* list = NULL;
+	ConfigList* list = nullptr;
 	ConfigItem* item;
 
 	if (configList->menuSkip(menu))
@@ -1859,7 +1859,7 @@  int main(int ac, char** av)
 	cmdline.process(*configApp);
 
 	if (cmdline.isSet(silent))
-		conf_set_message_callback(NULL);
+		conf_set_message_callback(nullptr);
 
 	QStringList args = cmdline.positionalArguments();
 	if (args.isEmpty())