kconfig: qconf: replace deprecated QString::sprintf() with QTextStream
QString::sprintf() is deprecated in the latest Qt version, and spawns a lot of warnings: HOSTCXX scripts/kconfig/qconf.o scripts/kconfig/qconf.cc: In member function ‘void ConfigInfoView::menuInfo()’: scripts/kconfig/qconf.cc:1090:61: warning: ‘QString& QString::sprintf(const char*, ...)’ is deprecated: Use asprintf(), arg() or QTextStream instead [-Wdeprecated-declarations] 1090 | head += QString().sprintf("<a href=\"s%s\">", sym->name); | ^ In file included from /usr/include/qt5/QtGui/qkeysequence.h:44, from /usr/include/qt5/QtWidgets/qaction.h:44, from /usr/include/qt5/QtWidgets/QAction:1, from scripts/kconfig/qconf.cc:7: /usr/include/qt5/QtCore/qstring.h:382:14: note: declared here 382 | QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); | ^~~~~~~ scripts/kconfig/qconf.cc:1099:60: warning: ‘QString& QString::sprintf(const char*, ...)’ is deprecated: Use asprintf(), arg() or QTextStream instead [-Wdeprecated-declarations] 1099 | head += QString().sprintf("<a href=\"s%s\">", sym->name); | ^ In file included from /usr/include/qt5/QtGui/qkeysequence.h:44, from /usr/include/qt5/QtWidgets/qaction.h:44, from /usr/include/qt5/QtWidgets/QAction:1, from scripts/kconfig/qconf.cc:7: /usr/include/qt5/QtCore/qstring.h:382:14: note: declared here 382 | QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); | ^~~~~~~ scripts/kconfig/qconf.cc:1127:90: warning: ‘QString& QString::sprintf(const char*, ...)’ is deprecated: Use asprintf(), arg() or QTextStream instead [-Wdeprecated-declarations] 1127 | debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno); | ^ In file included from /usr/include/qt5/QtGui/qkeysequence.h:44, from /usr/include/qt5/QtWidgets/qaction.h:44, from /usr/include/qt5/QtWidgets/QAction:1, from scripts/kconfig/qconf.cc:7: /usr/include/qt5/QtCore/qstring.h:382:14: note: declared here 382 | QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); | ^~~~~~~ scripts/kconfig/qconf.cc: In member function ‘QString ConfigInfoView::debug_info(symbol*)’: scripts/kconfig/qconf.cc:1150:68: warning: ‘QString& QString::sprintf(const char*, ...)’ is deprecated: Use asprintf(), arg() or QTextStream instead [-Wdeprecated-declarations] 1150 | debug += QString().sprintf("prompt: <a href=\"m%s\">", sym->name); | ^ In file included from /usr/include/qt5/QtGui/qkeysequence.h:44, from /usr/include/qt5/QtWidgets/qaction.h:44, from /usr/include/qt5/QtWidgets/QAction:1, from scripts/kconfig/qconf.cc:7: /usr/include/qt5/QtCore/qstring.h:382:14: note: declared here 382 | QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); | ^~~~~~~ scripts/kconfig/qconf.cc: In static member function ‘static void ConfigInfoView::expr_print_help(void*, symbol*, const char*)’: scripts/kconfig/qconf.cc:1225:59: warning: ‘QString& QString::sprintf(const char*, ...)’ is deprecated: Use asprintf(), arg() or QTextStream instead [-Wdeprecated-declarations] 1225 | *text += QString().sprintf("<a href=\"s%s\">", sym->name); | ^ In file included from /usr/include/qt5/QtGui/qkeysequence.h:44, from /usr/include/qt5/QtWidgets/qaction.h:44, from /usr/include/qt5/QtWidgets/QAction:1, from scripts/kconfig/qconf.cc:7: /usr/include/qt5/QtCore/qstring.h:382:14: note: declared here 382 | QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); | ^~~~~~~ The documentation also says: "Warning: We do not recommend using QString::asprintf() in new Qt code. Instead, consider using QTextStream or arg(), both of which support Unicode strings seamlessly and are type-safe." Use QTextStream as suggested. Reported-by: Robert Crawford <flacycads@cox.net> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
parent
68fd110b3e
commit
510bc3cb1d
|
@ -1076,75 +1076,80 @@ void ConfigInfoView::symbolInfo(void)
|
||||||
void ConfigInfoView::menuInfo(void)
|
void ConfigInfoView::menuInfo(void)
|
||||||
{
|
{
|
||||||
struct symbol* sym;
|
struct symbol* sym;
|
||||||
QString head, debug, help;
|
QString info;
|
||||||
|
QTextStream stream(&info);
|
||||||
|
|
||||||
sym = _menu->sym;
|
sym = _menu->sym;
|
||||||
if (sym) {
|
if (sym) {
|
||||||
if (_menu->prompt) {
|
if (_menu->prompt) {
|
||||||
head += "<big><b>";
|
stream << "<big><b>";
|
||||||
head += print_filter(_menu->prompt->text);
|
stream << print_filter(_menu->prompt->text);
|
||||||
head += "</b></big>";
|
stream << "</b></big>";
|
||||||
if (sym->name) {
|
if (sym->name) {
|
||||||
head += " (";
|
stream << " (";
|
||||||
if (showDebug())
|
if (showDebug())
|
||||||
head += QString().sprintf("<a href=\"s%s\">", sym->name);
|
stream << "<a href=\"s" << sym->name << "\">";
|
||||||
head += print_filter(sym->name);
|
stream << print_filter(sym->name);
|
||||||
if (showDebug())
|
if (showDebug())
|
||||||
head += "</a>";
|
stream << "</a>";
|
||||||
head += ")";
|
stream << ")";
|
||||||
}
|
}
|
||||||
} else if (sym->name) {
|
} else if (sym->name) {
|
||||||
head += "<big><b>";
|
stream << "<big><b>";
|
||||||
if (showDebug())
|
if (showDebug())
|
||||||
head += QString().sprintf("<a href=\"s%s\">", sym->name);
|
stream << "<a href=\"s" << sym->name << "\">";
|
||||||
head += print_filter(sym->name);
|
stream << print_filter(sym->name);
|
||||||
if (showDebug())
|
if (showDebug())
|
||||||
head += "</a>";
|
stream << "</a>";
|
||||||
head += "</b></big>";
|
stream << "</b></big>";
|
||||||
}
|
}
|
||||||
head += "<br><br>";
|
stream << "<br><br>";
|
||||||
|
|
||||||
if (showDebug())
|
if (showDebug())
|
||||||
debug = debug_info(sym);
|
stream << debug_info(sym);
|
||||||
|
|
||||||
} else if (_menu->prompt) {
|
} else if (_menu->prompt) {
|
||||||
head += "<big><b>";
|
stream << "<big><b>";
|
||||||
head += print_filter(_menu->prompt->text);
|
stream << print_filter(_menu->prompt->text);
|
||||||
head += "</b></big><br><br>";
|
stream << "</b></big><br><br>";
|
||||||
if (showDebug()) {
|
if (showDebug()) {
|
||||||
if (_menu->prompt->visible.expr) {
|
if (_menu->prompt->visible.expr) {
|
||||||
debug += " dep: ";
|
stream << " dep: ";
|
||||||
expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
|
expr_print(_menu->prompt->visible.expr,
|
||||||
debug += "<br><br>";
|
expr_print_help, &stream, E_NONE);
|
||||||
|
stream << "<br><br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (showDebug())
|
if (showDebug())
|
||||||
debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno);
|
stream << "defined at " << _menu->file->name << ":"
|
||||||
|
<< _menu->lineno << "<br><br>";
|
||||||
|
|
||||||
setText(head + debug);
|
setText(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConfigInfoView::debug_info(struct symbol *sym)
|
QString ConfigInfoView::debug_info(struct symbol *sym)
|
||||||
{
|
{
|
||||||
QString debug;
|
QString debug;
|
||||||
|
QTextStream stream(&debug);
|
||||||
|
|
||||||
debug += "type: ";
|
stream << "type: ";
|
||||||
debug += print_filter(sym_type_name(sym->type));
|
stream << print_filter(sym_type_name(sym->type));
|
||||||
if (sym_is_choice(sym))
|
if (sym_is_choice(sym))
|
||||||
debug += " (choice)";
|
stream << " (choice)";
|
||||||
debug += "<br>";
|
debug += "<br>";
|
||||||
if (sym->rev_dep.expr) {
|
if (sym->rev_dep.expr) {
|
||||||
debug += "reverse dep: ";
|
stream << "reverse dep: ";
|
||||||
expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE);
|
expr_print(sym->rev_dep.expr, expr_print_help, &stream, E_NONE);
|
||||||
debug += "<br>";
|
stream << "<br>";
|
||||||
}
|
}
|
||||||
for (struct property *prop = sym->prop; prop; prop = prop->next) {
|
for (struct property *prop = sym->prop; prop; prop = prop->next) {
|
||||||
switch (prop->type) {
|
switch (prop->type) {
|
||||||
case P_PROMPT:
|
case P_PROMPT:
|
||||||
case P_MENU:
|
case P_MENU:
|
||||||
debug += QString().sprintf("prompt: <a href=\"m%s\">", sym->name);
|
stream << "prompt: <a href=\"m" << sym->name << "\">";
|
||||||
debug += print_filter(prop->text);
|
stream << print_filter(prop->text);
|
||||||
debug += "</a><br>";
|
stream << "</a><br>";
|
||||||
break;
|
break;
|
||||||
case P_DEFAULT:
|
case P_DEFAULT:
|
||||||
case P_SELECT:
|
case P_SELECT:
|
||||||
|
@ -1152,30 +1157,33 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
|
||||||
case P_COMMENT:
|
case P_COMMENT:
|
||||||
case P_IMPLY:
|
case P_IMPLY:
|
||||||
case P_SYMBOL:
|
case P_SYMBOL:
|
||||||
debug += prop_get_type_name(prop->type);
|
stream << prop_get_type_name(prop->type);
|
||||||
debug += ": ";
|
stream << ": ";
|
||||||
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
|
expr_print(prop->expr, expr_print_help,
|
||||||
debug += "<br>";
|
&stream, E_NONE);
|
||||||
|
stream << "<br>";
|
||||||
break;
|
break;
|
||||||
case P_CHOICE:
|
case P_CHOICE:
|
||||||
if (sym_is_choice(sym)) {
|
if (sym_is_choice(sym)) {
|
||||||
debug += "choice: ";
|
stream << "choice: ";
|
||||||
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
|
expr_print(prop->expr, expr_print_help,
|
||||||
debug += "<br>";
|
&stream, E_NONE);
|
||||||
|
stream << "<br>";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
debug += "unknown property: ";
|
stream << "unknown property: ";
|
||||||
debug += prop_get_type_name(prop->type);
|
stream << prop_get_type_name(prop->type);
|
||||||
debug += "<br>";
|
stream << "<br>";
|
||||||
}
|
}
|
||||||
if (prop->visible.expr) {
|
if (prop->visible.expr) {
|
||||||
debug += " dep: ";
|
stream << " dep: ";
|
||||||
expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
|
expr_print(prop->visible.expr, expr_print_help,
|
||||||
debug += "<br>";
|
&stream, E_NONE);
|
||||||
|
stream << "<br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug += "<br>";
|
stream << "<br>";
|
||||||
|
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
@ -1213,15 +1221,15 @@ QString ConfigInfoView::print_filter(const QString &str)
|
||||||
|
|
||||||
void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str)
|
void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str)
|
||||||
{
|
{
|
||||||
QString* text = reinterpret_cast<QString*>(data);
|
QTextStream *stream = reinterpret_cast<QTextStream *>(data);
|
||||||
QString str2 = print_filter(str);
|
|
||||||
|
|
||||||
if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
|
if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
|
||||||
*text += QString().sprintf("<a href=\"s%s\">", sym->name);
|
*stream << "<a href=\"s" << sym->name << "\">";
|
||||||
*text += str2;
|
*stream << print_filter(str);
|
||||||
*text += "</a>";
|
*stream << "</a>";
|
||||||
} else
|
} else {
|
||||||
*text += str2;
|
*stream << print_filter(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigInfoView::clicked(const QUrl &url)
|
void ConfigInfoView::clicked(const QUrl &url)
|
||||||
|
|
Loading…
Reference in New Issue