* [PATCH 1/7] kconfig: qconf: use QByteArray API instead of manually constructing a string
2024-10-23 6:26 [PATCH 0/7] improve qconfig C++ code Rolf Eike Beer
@ 2024-10-23 6:29 ` Rolf Eike Beer
2024-10-23 16:37 ` Masahiro Yamada
2024-10-23 6:31 ` [PATCH 2/7] kconfig: qconf: use QString to store path to configuration file Rolf Eike Beer
` (5 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Rolf Eike Beer @ 2024-10-23 6:29 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel
Using a naked char[] here isn't necessary as QByteArray has a nice API for all
of this. Calling constData() will also always return a 0-terminated string so no
further handling is required. And then the whole manual memory handling can go
away as QByteArray will care for this when it goes out of scope.
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
---
scripts/kconfig/qconf.cc | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index e260cab1c2af..742ca6ed289b 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1165,25 +1165,17 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
void ConfigInfoView::clicked(const QUrl &url)
{
QByteArray str = url.toEncoded();
- const std::size_t count = str.size();
- char *data = new char[count + 2]; // '$' + '\0'
struct symbol **result;
struct menu *m = NULL;
- if (count < 1) {
- delete[] data;
+ if (str.isEmpty())
return;
- }
-
- memcpy(data, str.constData(), count);
- data[count] = '\0';
/* Seek for exact match */
- data[0] = '^';
- strcat(data, "$");
- result = sym_re_search(data);
+ str[0] = '^';
+ str.append('$');
+ result = sym_re_search(str.constData());
if (!result) {
- delete[] data;
return;
}
@@ -1206,7 +1198,6 @@ void ConfigInfoView::clicked(const QUrl &url)
}
free(result);
- delete[] data;
}
void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)
--
2.47.0
--
Rolf Eike Beer
emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail info@emlix.com
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com
emlix - your embedded Linux partner
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 1/7] kconfig: qconf: use QByteArray API instead of manually constructing a string
2024-10-23 6:29 ` [PATCH 1/7] kconfig: qconf: use QByteArray API instead of manually constructing a string Rolf Eike Beer
@ 2024-10-23 16:37 ` Masahiro Yamada
2024-10-23 19:07 ` Masahiro Yamada
0 siblings, 1 reply; 19+ messages in thread
From: Masahiro Yamada @ 2024-10-23 16:37 UTC (permalink / raw)
To: Rolf Eike Beer; +Cc: linux-kbuild, linux-kernel
On Wed, Oct 23, 2024 at 3:29 PM Rolf Eike Beer <eb@emlix.com> wrote:
>
> Using a naked char[] here isn't necessary as QByteArray has a nice API for all
> of this. Calling constData() will also always return a 0-terminated string so no
> further handling is required. And then the whole manual memory handling can go
> away as QByteArray will care for this when it goes out of scope.
>
> Signed-off-by: Rolf Eike Beer <eb@emlix.com>
> ---
I do not need this patch because I can refactor this function even deeper.
I have locally kept several clean-up patches, but I have not got around to
submitting them.
I will send some of them later.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/7] kconfig: qconf: use QByteArray API instead of manually constructing a string
2024-10-23 16:37 ` Masahiro Yamada
@ 2024-10-23 19:07 ` Masahiro Yamada
2024-10-24 7:02 ` Rolf Eike Beer
0 siblings, 1 reply; 19+ messages in thread
From: Masahiro Yamada @ 2024-10-23 19:07 UTC (permalink / raw)
To: Rolf Eike Beer; +Cc: linux-kbuild, linux-kernel
On Thu, Oct 24, 2024 at 1:37 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Wed, Oct 23, 2024 at 3:29 PM Rolf Eike Beer <eb@emlix.com> wrote:
> >
> > Using a naked char[] here isn't necessary as QByteArray has a nice API for all
> > of this. Calling constData() will also always return a 0-terminated string so no
> > further handling is required. And then the whole manual memory handling can go
> > away as QByteArray will care for this when it goes out of scope.
> >
> > Signed-off-by: Rolf Eike Beer <eb@emlix.com>
> > ---
>
> I do not need this patch because I can refactor this function even deeper.
>
> I have locally kept several clean-up patches, but I have not got around to
> submitting them.
>
> I will send some of them later.
https://lore.kernel.org/linux-kbuild/20241023181823.138524-12-masahiroy@kernel.org/T/#u
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/7] kconfig: qconf: use QByteArray API instead of manually constructing a string
2024-10-23 19:07 ` Masahiro Yamada
@ 2024-10-24 7:02 ` Rolf Eike Beer
0 siblings, 0 replies; 19+ messages in thread
From: Rolf Eike Beer @ 2024-10-24 7:02 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1462 bytes --]
On Mittwoch, 23. Oktober 2024 21:07:41 Mitteleuropäische Sommerzeit Masahiro
Yamada wrote:
> On Thu, Oct 24, 2024 at 1:37 AM Masahiro Yamada <masahiroy@kernel.org>
wrote:
> > On Wed, Oct 23, 2024 at 3:29 PM Rolf Eike Beer <eb@emlix.com> wrote:
> > > Using a naked char[] here isn't necessary as QByteArray has a nice API
> > > for all of this. Calling constData() will also always return a
> > > 0-terminated string so no further handling is required. And then the
> > > whole manual memory handling can go away as QByteArray will care for
> > > this when it goes out of scope.
> > >
> > > Signed-off-by: Rolf Eike Beer <eb@emlix.com>
> > > ---
> >
> > I do not need this patch because I can refactor this function even deeper.
> >
> > I have locally kept several clean-up patches, but I have not got around to
> > submitting them.
> >
> > I will send some of them later.
>
> https://lore.kernel.org/linux-kbuild/20241023181823.138524-12-masahiroy@kern
> el.org/T/#u
Even better, thanks!
--
Rolf Eike Beer
emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail info@emlix.com
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com
emlix - your embedded Linux partner
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 313 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/7] kconfig: qconf: use QString to store path to configuration file
2024-10-23 6:26 [PATCH 0/7] improve qconfig C++ code Rolf Eike Beer
2024-10-23 6:29 ` [PATCH 1/7] kconfig: qconf: use QByteArray API instead of manually constructing a string Rolf Eike Beer
@ 2024-10-23 6:31 ` Rolf Eike Beer
2024-10-23 16:37 ` Masahiro Yamada
2024-10-23 6:32 ` [PATCH 3/7] kconfig: qconf: use preferred form of QString API Rolf Eike Beer
` (4 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Rolf Eike Beer @ 2024-10-23 6:31 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel
This is the native type used by the file dialogs and avoids any hassle with
filename encoding when converting this back and forth to a character array.
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
---
scripts/kconfig/qconf.cc | 24 ++++++------------------
scripts/kconfig/qconf.h | 2 +-
2 files changed, 7 insertions(+), 19 deletions(-)
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 742ca6ed289b..54640f6b29e2 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1380,7 +1380,7 @@ ConfigMainWindow::ConfigMainWindow(void)
conf_set_changed_callback(conf_changed);
- configname = xstrdup(conf_get_configname());
+ configname = conf_get_configname();
QAction *saveAsAction = new QAction("Save &As...", this);
connect(saveAsAction, &QAction::triggered,
@@ -1519,28 +1519,22 @@ ConfigMainWindow::ConfigMainWindow(void)
void ConfigMainWindow::loadConfig(void)
{
QString str;
- QByteArray ba;
- const char *name;
str = QFileDialog::getOpenFileName(this, "", configname);
if (str.isNull())
return;
- ba = str.toLocal8Bit();
- name = ba.data();
-
- if (conf_read(name))
+ if (conf_read(str.toLocal8Bit().constData()))
QMessageBox::information(this, "qconf", "Unable to load configuration!");
- free(configname);
- configname = xstrdup(name);
+ configname = str;
ConfigList::updateListAllForAll();
}
bool ConfigMainWindow::saveConfig(void)
{
- if (conf_write(configname)) {
+ if (conf_write(configname.toLocal8Bit().constData())) {
QMessageBox::information(this, "qconf", "Unable to save configuration!");
return false;
}
@@ -1552,23 +1546,17 @@ bool ConfigMainWindow::saveConfig(void)
void ConfigMainWindow::saveConfigAs(void)
{
QString str;
- QByteArray ba;
- const char *name;
str = QFileDialog::getSaveFileName(this, "", configname);
if (str.isNull())
return;
- ba = str.toLocal8Bit();
- name = ba.data();
-
- if (conf_write(name)) {
+ if (conf_write(str.toLocal8Bit().constData())) {
QMessageBox::information(this, "qconf", "Unable to save configuration!");
}
conf_write_autoconf(0);
- free(configname);
- configname = xstrdup(name);
+ configname = str;
}
void ConfigMainWindow::searchConfig(void)
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h
index 53373064d90a..aab25ece95c6 100644
--- a/scripts/kconfig/qconf.h
+++ b/scripts/kconfig/qconf.h
@@ -237,7 +237,7 @@ public slots:
class ConfigMainWindow : public QMainWindow {
Q_OBJECT
- char *configname;
+ QString configname;
static QAction *saveAction;
static void conf_changed(bool);
public:
--
2.47.0
--
Rolf Eike Beer
emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail info@emlix.com
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com
emlix - your embedded Linux partner
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 3/7] kconfig: qconf: use preferred form of QString API
2024-10-23 6:26 [PATCH 0/7] improve qconfig C++ code Rolf Eike Beer
2024-10-23 6:29 ` [PATCH 1/7] kconfig: qconf: use QByteArray API instead of manually constructing a string Rolf Eike Beer
2024-10-23 6:31 ` [PATCH 2/7] kconfig: qconf: use QString to store path to configuration file Rolf Eike Beer
@ 2024-10-23 6:32 ` Rolf Eike Beer
2024-10-23 16:38 ` Masahiro Yamada
2024-10-23 6:33 ` [PATCH 4/7] kconfig: qconf: use QCommandLineParser Rolf Eike Beer
` (3 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Rolf Eike Beer @ 2024-10-23 6:32 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
---
scripts/kconfig/qconf.cc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 54640f6b29e2..6a653ebe9df3 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1520,8 +1520,8 @@ void ConfigMainWindow::loadConfig(void)
{
QString str;
- str = QFileDialog::getOpenFileName(this, "", configname);
- if (str.isNull())
+ str = QFileDialog::getOpenFileName(this, QString(), configname);
+ if (str.isEmpty())
return;
if (conf_read(str.toLocal8Bit().constData()))
@@ -1547,8 +1547,8 @@ void ConfigMainWindow::saveConfigAs(void)
{
QString str;
- str = QFileDialog::getSaveFileName(this, "", configname);
- if (str.isNull())
+ str = QFileDialog::getSaveFileName(this, QString(), configname);
+ if (str.isEmpty())
return;
if (conf_write(str.toLocal8Bit().constData())) {
--
2.47.0
--
Rolf Eike Beer
emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail info@emlix.com
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com
emlix - your embedded Linux partner
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 3/7] kconfig: qconf: use preferred form of QString API
2024-10-23 6:32 ` [PATCH 3/7] kconfig: qconf: use preferred form of QString API Rolf Eike Beer
@ 2024-10-23 16:38 ` Masahiro Yamada
0 siblings, 0 replies; 19+ messages in thread
From: Masahiro Yamada @ 2024-10-23 16:38 UTC (permalink / raw)
To: Rolf Eike Beer; +Cc: linux-kbuild, linux-kernel
The code looks good to me, but please describe something
in the commit message body.
For example, you can quote:
"We recommend that you always use the isEmpty() function and avoid isNull()"
from the QString documentation. [1]
[1] https://doc.qt.io/qt-6/qstring.html#distinction-between-null-and-empty-strings
On Wed, Oct 23, 2024 at 3:32 PM Rolf Eike Beer <eb@emlix.com> wrote:
>
> Signed-off-by: Rolf Eike Beer <eb@emlix.com>
> ---
> scripts/kconfig/qconf.cc | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
> index 54640f6b29e2..6a653ebe9df3 100644
> --- a/scripts/kconfig/qconf.cc
> +++ b/scripts/kconfig/qconf.cc
> @@ -1520,8 +1520,8 @@ void ConfigMainWindow::loadConfig(void)
> {
> QString str;
>
> - str = QFileDialog::getOpenFileName(this, "", configname);
> - if (str.isNull())
> + str = QFileDialog::getOpenFileName(this, QString(), configname);
> + if (str.isEmpty())
> return;
>
> if (conf_read(str.toLocal8Bit().constData()))
> @@ -1547,8 +1547,8 @@ void ConfigMainWindow::saveConfigAs(void)
> {
> QString str;
>
> - str = QFileDialog::getSaveFileName(this, "", configname);
> - if (str.isNull())
> + str = QFileDialog::getSaveFileName(this, QString(), configname);
> + if (str.isEmpty())
> return;
>
> if (conf_write(str.toLocal8Bit().constData())) {
> --
> 2.47.0
>
>
> --
> Rolf Eike Beer
>
> emlix GmbH
> Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
> Phone +49 (0)551 30664-0, e-mail info@emlix.com
> District Court of Göttingen, Registry Number HR B 3160
> Managing Directors: Heike Jordan, Dr. Uwe Kracke
> VAT ID No. DE 205 198 055
> Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
> Office Bonn: Bachstr. 6, 53115 Bonn, Germany
> http://www.emlix.com
>
> emlix - your embedded Linux partner
>
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 4/7] kconfig: qconf: use QCommandLineParser
2024-10-23 6:26 [PATCH 0/7] improve qconfig C++ code Rolf Eike Beer
` (2 preceding siblings ...)
2024-10-23 6:32 ` [PATCH 3/7] kconfig: qconf: use preferred form of QString API Rolf Eike Beer
@ 2024-10-23 6:33 ` Rolf Eike Beer
2024-10-23 16:39 ` Masahiro Yamada
2024-10-23 6:34 ` [PATCH 5/7] kconfig: qconf: use nullptr in C++11 code Rolf Eike Beer
` (2 subsequent siblings)
6 siblings, 1 reply; 19+ messages in thread
From: Rolf Eike Beer @ 2024-10-23 6:33 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel
This has a much nicer output without manual processing. It also adds window
management options from Qt for free.
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
---
scripts/kconfig/qconf.cc | 44 ++++++++++++++++------------------------
1 file changed, 17 insertions(+), 27 deletions(-)
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 6a653ebe9df3..313a51941825 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -8,6 +8,7 @@
#include <QActionGroup>
#include <QApplication>
#include <QCloseEvent>
+#include <QCommandLineParser>
#include <QDebug>
#include <QFileDialog>
#include <QLabel>
@@ -1844,41 +1845,30 @@ void fixup_rootmenu(struct menu *menu)
}
}
-static const char *progname;
-
-static void usage(void)
-{
- printf("%s [-s] <config>\n", progname);
- exit(0);
-}
-
int main(int ac, char** av)
{
ConfigMainWindow* v;
- const char *name;
+ configApp = new QApplication(ac, av);
+ QCommandLineParser cmdline;
+ QCommandLineOption silent("s", "silent");
- progname = av[0];
- if (ac > 1 && av[1][0] == '-') {
- switch (av[1][1]) {
- case 's':
- conf_set_message_callback(NULL);
- break;
- case 'h':
- case '?':
- usage();
- }
- name = av[2];
- } else
- name = av[1];
- if (!name)
- usage();
+ cmdline.addOption(silent);
+ cmdline.addHelpOption();
+ cmdline.addPositionalArgument("file", "config file to open", "Kconfig");
+
+ cmdline.process(*configApp);
+
+ if (cmdline.isSet(silent))
+ conf_set_message_callback(NULL);
- conf_parse(name);
+ QStringList args = cmdline.positionalArguments();
+ if (args.isEmpty())
+ cmdline.showHelp(1);
+
+ conf_parse(args.first().toLocal8Bit().constData());
fixup_rootmenu(&rootmenu);
//zconfdump(stdout);
- configApp = new QApplication(ac, av);
-
configSettings = new ConfigSettings();
configSettings->beginGroup("/kconfig/qconf");
v = new ConfigMainWindow();
--
2.47.0
--
Rolf Eike Beer
emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail info@emlix.com
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com
emlix - your embedded Linux partner
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 4/7] kconfig: qconf: use QCommandLineParser
2024-10-23 6:33 ` [PATCH 4/7] kconfig: qconf: use QCommandLineParser Rolf Eike Beer
@ 2024-10-23 16:39 ` Masahiro Yamada
2024-10-24 11:28 ` Masahiro Yamada
0 siblings, 1 reply; 19+ messages in thread
From: Masahiro Yamada @ 2024-10-23 16:39 UTC (permalink / raw)
To: Rolf Eike Beer; +Cc: linux-kbuild, linux-kernel
On Wed, Oct 23, 2024 at 3:33 PM Rolf Eike Beer <eb@emlix.com> wrote:
>
> This has a much nicer output without manual processing. It also adds window
> management options from Qt for free.
>
> Signed-off-by: Rolf Eike Beer <eb@emlix.com>
> ---
The help message looks as follows:
$ ./scripts/kconfig/qconf --help
QSocketNotifier: Can only be used with threads started with QThread
Usage: ./scripts/kconfig/qconf [options] Kconfig
Options:
-s silent
-h, --help Displays help on commandline options.
--help-all Displays help including Qt specific options.
Arguments:
file config file to open
I want to see something better for the explanation of '-s'
and I want 'file' and 'Kconfig' to match.
> int main(int ac, char** av)
> {
> ConfigMainWindow* v;
> - const char *name;
> + configApp = new QApplication(ac, av);
> + QCommandLineParser cmdline;
Please rename 'cmdline' to 'parser' because this is
used in the code example.
https://doc.qt.io/qt-6/qcommandlineparser.html#details
> + QCommandLineOption silent("s", "silent");
How about this ?
silent("s", "Print this message and exit.");
The description is consistent with
"./scripts/kconfig/conf --help".
> + cmdline.addOption(silent);
> + cmdline.addHelpOption();
> + cmdline.addPositionalArgument("file", "config file to open", "Kconfig");
I think the third parameter is unneeded.
Then, the help message will look better.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH 4/7] kconfig: qconf: use QCommandLineParser
2024-10-23 16:39 ` Masahiro Yamada
@ 2024-10-24 11:28 ` Masahiro Yamada
0 siblings, 0 replies; 19+ messages in thread
From: Masahiro Yamada @ 2024-10-24 11:28 UTC (permalink / raw)
To: Rolf Eike Beer; +Cc: linux-kbuild, linux-kernel
On Thu, Oct 24, 2024 at 1:39 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Wed, Oct 23, 2024 at 3:33 PM Rolf Eike Beer <eb@emlix.com> wrote:
> >
> > This has a much nicer output without manual processing. It also adds window
> > management options from Qt for free.
> >
> > Signed-off-by: Rolf Eike Beer <eb@emlix.com>
> > ---
>
> The help message looks as follows:
>
>
> $ ./scripts/kconfig/qconf --help
> QSocketNotifier: Can only be used with threads started with QThread
> Usage: ./scripts/kconfig/qconf [options] Kconfig
>
> Options:
> -s silent
> -h, --help Displays help on commandline options.
> --help-all Displays help including Qt specific options.
>
> Arguments:
> file config file to open
"config file" is a bit confusing. (it sounds like ".config").
The positional argument specifies the top-level Kconfig.
I added this to the help of scripts/kconfig/conf:
https://lore.kernel.org/linux-kbuild/20241024112548.1438155-1-masahiroy@kernel.org/T/#u
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 5/7] kconfig: qconf: use nullptr in C++11 code
2024-10-23 6:26 [PATCH 0/7] improve qconfig C++ code Rolf Eike Beer
` (3 preceding siblings ...)
2024-10-23 6:33 ` [PATCH 4/7] kconfig: qconf: use QCommandLineParser Rolf Eike Beer
@ 2024-10-23 6:34 ` Rolf Eike Beer
2024-10-23 16:41 ` Masahiro Yamada
2024-10-23 6:36 ` [PATCH 6/7] kconfig: qconf: use default platform shortcuts Rolf Eike Beer
2024-10-23 6:39 ` [PATCH 7/7] kconfig: qconf: simplify character replacement Rolf Eike Beer
6 siblings, 1 reply; 19+ messages in thread
From: Rolf Eike Beer @ 2024-10-23 6:34 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel
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(-)
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())
--
2.47.0
--
Rolf Eike Beer
emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail info@emlix.com
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com
emlix - your embedded Linux partner
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 5/7] kconfig: qconf: use nullptr in C++11 code
2024-10-23 6:34 ` [PATCH 5/7] kconfig: qconf: use nullptr in C++11 code Rolf Eike Beer
@ 2024-10-23 16:41 ` Masahiro Yamada
2024-10-24 7:05 ` Rolf Eike Beer
0 siblings, 1 reply; 19+ messages in thread
From: Masahiro Yamada @ 2024-10-23 16:41 UTC (permalink / raw)
To: Rolf Eike Beer; +Cc: linux-kbuild, linux-kernel
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 5/7] kconfig: qconf: use nullptr in C++11 code
2024-10-23 16:41 ` Masahiro Yamada
@ 2024-10-24 7:05 ` Rolf Eike Beer
0 siblings, 0 replies; 19+ messages in thread
From: Rolf Eike Beer @ 2024-10-24 7:05 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1438 bytes --]
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
--
Rolf Eike Beer
emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail info@emlix.com
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com
emlix - your embedded Linux partner
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 313 bytes --]
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 6/7] kconfig: qconf: use default platform shortcuts
2024-10-23 6:26 [PATCH 0/7] improve qconfig C++ code Rolf Eike Beer
` (4 preceding siblings ...)
2024-10-23 6:34 ` [PATCH 5/7] kconfig: qconf: use nullptr in C++11 code Rolf Eike Beer
@ 2024-10-23 6:36 ` Rolf Eike Beer
2024-10-23 16:48 ` Masahiro Yamada
2024-10-23 6:39 ` [PATCH 7/7] kconfig: qconf: simplify character replacement Rolf Eike Beer
6 siblings, 1 reply; 19+ messages in thread
From: Rolf Eike Beer @ 2024-10-23 6:36 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel
This renames "Load" to "Open" and switches Ctrl-L to Ctrl-O for the default
platforms. This may break the workflow for those used to it, but will make it
actually work for everyone else like me who would just expect the default
behavior. Add some more standard shortcuts where available. If they replace
the existing shortcuts they would have the same value in my case.
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
---
scripts/kconfig/qconf.cc | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 563ef8543d7c..4b2f707c9203 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1361,21 +1361,22 @@ ConfigMainWindow::ConfigMainWindow(void)
configList->setFocus();
backAction = new QAction(QPixmap(xpm_back), "Back", this);
+ backAction->setShortcut(QKeySequence::Back);
connect(backAction, &QAction::triggered,
this, &ConfigMainWindow::goBack);
QAction *quitAction = new QAction("&Quit", this);
- quitAction->setShortcut(Qt::CTRL | Qt::Key_Q);
+ quitAction->setShortcut(QKeySequence::Quit);
connect(quitAction, &QAction::triggered,
this, &ConfigMainWindow::close);
- QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this);
- loadAction->setShortcut(Qt::CTRL | Qt::Key_L);
+ QAction *loadAction = new QAction(QPixmap(xpm_load), "&Open", this);
+ loadAction->setShortcut(QKeySequence::Open);
connect(loadAction, &QAction::triggered,
this, &ConfigMainWindow::loadConfig);
saveAction = new QAction(QPixmap(xpm_save), "&Save", this);
- saveAction->setShortcut(Qt::CTRL | Qt::Key_S);
+ saveAction->setShortcut(QKeySequence::Save);
connect(saveAction, &QAction::triggered,
this, &ConfigMainWindow::saveConfig);
@@ -1384,10 +1385,11 @@ ConfigMainWindow::ConfigMainWindow(void)
configname = conf_get_configname();
QAction *saveAsAction = new QAction("Save &As...", this);
+ saveAsAction->setShortcut(QKeySequence::SaveAs);
connect(saveAsAction, &QAction::triggered,
this, &ConfigMainWindow::saveConfigAs);
QAction *searchAction = new QAction("&Find", this);
- searchAction->setShortcut(Qt::CTRL | Qt::Key_F);
+ searchAction->setShortcut(QKeySequence::Find);
connect(searchAction, &QAction::triggered,
this, &ConfigMainWindow::searchConfig);
singleViewAction = new QAction(QPixmap(xpm_single_view), "Single View", this);
--
2.47.0
--
Rolf Eike Beer
emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail info@emlix.com
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com
emlix - your embedded Linux partner
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 6/7] kconfig: qconf: use default platform shortcuts
2024-10-23 6:36 ` [PATCH 6/7] kconfig: qconf: use default platform shortcuts Rolf Eike Beer
@ 2024-10-23 16:48 ` Masahiro Yamada
0 siblings, 0 replies; 19+ messages in thread
From: Masahiro Yamada @ 2024-10-23 16:48 UTC (permalink / raw)
To: Rolf Eike Beer; +Cc: linux-kbuild, linux-kernel
On Wed, Oct 23, 2024 at 3:36 PM Rolf Eike Beer <eb@emlix.com> wrote:
>
> This renames "Load" to "Open" and switches Ctrl-L to Ctrl-O for the default
> platforms. This may break the workflow for those used to it, but will make it
> actually work for everyone else like me who would just expect the default
> behavior. Add some more standard shortcuts where available. If they replace
> the existing shortcuts they would have the same value in my case.
>
> Signed-off-by: Rolf Eike Beer <eb@emlix.com>
> ---
Applied to linux-kbuild. Thanks!
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 7/7] kconfig: qconf: simplify character replacement
2024-10-23 6:26 [PATCH 0/7] improve qconfig C++ code Rolf Eike Beer
` (5 preceding siblings ...)
2024-10-23 6:36 ` [PATCH 6/7] kconfig: qconf: use default platform shortcuts Rolf Eike Beer
@ 2024-10-23 6:39 ` Rolf Eike Beer
2024-10-23 16:51 ` Masahiro Yamada
6 siblings, 1 reply; 19+ messages in thread
From: Rolf Eike Beer @ 2024-10-23 6:39 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel
Replace the hand crafted lookup table with a QHash. This has the nice benefit
that the added offsets can not get out of sync with the length of the
replacement strings.
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
---
scripts/kconfig/qconf.cc | 33 ++++++++++++---------------------
1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 4b2f707c9203..f07a463c5760 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1123,28 +1123,19 @@ QString ConfigInfoView::print_filter(const QString &str)
{
QRegularExpression re("[<>&\"\\n]");
QString res = str;
+
+ QHash<QChar, QString> patterns;
+ patterns['<'] = "<";
+ patterns['>'] = ">";
+ patterns['&'] = "&";
+ patterns['"'] = """;
+ patterns['\n'] = "<br>";
+
for (int i = 0; (i = res.indexOf(re, i)) >= 0;) {
- switch (res[i].toLatin1()) {
- case '<':
- res.replace(i, 1, "<");
- i += 4;
- break;
- case '>':
- res.replace(i, 1, ">");
- i += 4;
- break;
- case '&':
- res.replace(i, 1, "&");
- i += 5;
- break;
- case '"':
- res.replace(i, 1, """);
- i += 6;
- break;
- case '\n':
- res.replace(i, 1, "<br>");
- i += 4;
- break;
+ const QString n = patterns.value(res[i], QString());
+ if (!n.isEmpty()) {
+ res.replace(i, 1, n);
+ i += n.length();
}
}
return res;
--
2.47.0
--
Rolf Eike Beer
emlix GmbH
Headquarters: Berliner Str. 12, 37073 Göttingen, Germany
Phone +49 (0)551 30664-0, e-mail info@emlix.com
District Court of Göttingen, Registry Number HR B 3160
Managing Directors: Heike Jordan, Dr. Uwe Kracke
VAT ID No. DE 205 198 055
Office Berlin: Panoramastr. 1, 10178 Berlin, Germany
Office Bonn: Bachstr. 6, 53115 Bonn, Germany
http://www.emlix.com
emlix - your embedded Linux partner
^ permalink raw reply related [flat|nested] 19+ messages in thread