QDBusMarshaller: fix -Wformat-overflow
Says GCC: qdbusmarshaller.cpp: In member function ‘QDBusMarshaller* QDBusMarshaller::beginMap(QMetaType, QMetaType)’: qdbusmarshaller.cpp:286:17: warning: ‘%s’ directive argument is null [-Wformat-overflow=] 286 | qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " | ^ Fix by manual checking. It's a False Positive, because QString::asprintf() can handle nullptr strings just find, but let's make GCC happy. Since the code snippet appears multiple times, even though GCC only warns about one of them, take this opportunity to factor the code out into a cold helper function. Change-Id: I1d642f2465f34b670b179646185cba05cb16e573 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
28fbed2f5c
commit
ebee8a1336
@ -155,6 +155,7 @@ public:
|
||||
bool skipSignature;
|
||||
|
||||
private:
|
||||
Q_DECL_COLD_FUNCTION void unregisteredTypeError(QMetaType t);
|
||||
Q_DISABLE_COPY_MOVE(QDBusMarshaller)
|
||||
};
|
||||
|
||||
|
@ -59,6 +59,16 @@ QDBusMarshaller::~QDBusMarshaller()
|
||||
close();
|
||||
}
|
||||
|
||||
void QDBusMarshaller::unregisteredTypeError(QMetaType id)
|
||||
{
|
||||
const char *name = id.name();
|
||||
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
|
||||
"Use qDBusRegisterMetaType to register it",
|
||||
name ? name : "", id.id());
|
||||
error(QLatin1String("Unregistered type %1 passed in arguments")
|
||||
.arg(QLatin1String(id.name())));
|
||||
}
|
||||
|
||||
inline QString QDBusMarshaller::currentSignature()
|
||||
{
|
||||
if (message)
|
||||
@ -208,11 +218,7 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg)
|
||||
signature = QDBusMetaType::typeToSignature(id);
|
||||
}
|
||||
if (!signature) {
|
||||
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
|
||||
"Use qDBusRegisterMetaType to register it",
|
||||
id.name(), id.id());
|
||||
error(QLatin1String("Unregistered type %1 passed in arguments")
|
||||
.arg(QLatin1String(id.name())));
|
||||
unregisteredTypeError(id);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -250,11 +256,7 @@ inline QDBusMarshaller *QDBusMarshaller::beginArray(QMetaType id)
|
||||
{
|
||||
const char *signature = QDBusMetaType::typeToSignature(id);
|
||||
if (!signature) {
|
||||
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
|
||||
"Use qDBusRegisterMetaType to register it",
|
||||
id.name(), id.id());
|
||||
error(QLatin1String("Unregistered type %1 passed in arguments")
|
||||
.arg(QLatin1String(id.name())));
|
||||
unregisteredTypeError(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -265,11 +267,7 @@ inline QDBusMarshaller *QDBusMarshaller::beginMap(QMetaType kid, QMetaType vid)
|
||||
{
|
||||
const char *ksignature = QDBusMetaType::typeToSignature(kid);
|
||||
if (!ksignature) {
|
||||
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
|
||||
"Use qDBusRegisterMetaType to register it",
|
||||
kid.name(), kid.id());
|
||||
error(QLatin1String("Unregistered type %1 passed in arguments")
|
||||
.arg(QLatin1String(kid.name())));
|
||||
unregisteredTypeError(kid);
|
||||
return this;
|
||||
}
|
||||
if (ksignature[1] != 0 || !QDBusUtil::isValidBasicType(*ksignature)) {
|
||||
@ -282,12 +280,7 @@ inline QDBusMarshaller *QDBusMarshaller::beginMap(QMetaType kid, QMetaType vid)
|
||||
|
||||
const char *vsignature = QDBusMetaType::typeToSignature(vid);
|
||||
if (!vsignature) {
|
||||
const char *typeName = vid.name();
|
||||
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
|
||||
"Use qDBusRegisterMetaType to register it",
|
||||
typeName, vid.id());
|
||||
error(QLatin1String("Unregistered type %1 passed in arguments")
|
||||
.arg(QLatin1String(typeName)));
|
||||
unregisteredTypeError(vid);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -414,11 +407,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
|
||||
|
||||
const char *signature = QDBusMetaType::typeToSignature(id);
|
||||
if (!signature) {
|
||||
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
|
||||
"Use qDBusRegisterMetaType to register it",
|
||||
id.name(), id.id());
|
||||
error(QLatin1String("Unregistered type %1 passed in arguments")
|
||||
.arg(QLatin1String(id.name())));
|
||||
unregisteredTypeError(id);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user