From 0aba7fbb5837c81351e7e4ba43044a8dbb37098c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 1 Mar 2014 10:39:30 -0800 Subject: [PATCH] Always initialize integer types in D-Bus demarshalling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If you tried to demarshall in a write-only QDBusArgument, the class would print a warning, but will continue running nonetheless. So instead just initialize everything, despite the warning. qdbusargument.cpp:1138:30: error: ‘d’ may be used uninitialized in this function [-Werror=maybe-uninitialized] qdbusargument.cpp:1165:33: error: ‘s’ may be used uninitialized in this function [-Werror=maybe-uninitialized] qdbusargument.cpp:1301:15: error: ‘y’ may be used uninitialized in this function [-Werror=maybe-uninitialized] etc. Change-Id: I6d713b4a7b7639e31f3b39bb488ad3ed3ab3fa4a Reviewed-by: Frederik Gladhorn Reviewed-by: Jędrzej Nowacki --- src/dbus/qdbusargument.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp index 83a544c4e36..6157694d12e 100644 --- a/src/dbus/qdbusargument.cpp +++ b/src/dbus/qdbusargument.cpp @@ -605,6 +605,8 @@ const QDBusArgument &QDBusArgument::operator>>(uchar &arg) const { if (QDBusArgumentPrivate::checkReadAndDetach(d)) arg = d->demarshaller()->toByte(); + else + arg = 0; return *this; } @@ -617,6 +619,8 @@ const QDBusArgument &QDBusArgument::operator>>(bool &arg) const { if (QDBusArgumentPrivate::checkReadAndDetach(d)) arg = d->demarshaller()->toBool(); + else + arg = false; return *this; } @@ -629,6 +633,8 @@ const QDBusArgument &QDBusArgument::operator>>(ushort &arg) const { if (QDBusArgumentPrivate::checkReadAndDetach(d)) arg = d->demarshaller()->toUShort(); + else + arg = 0; return *this; } @@ -641,6 +647,8 @@ const QDBusArgument &QDBusArgument::operator>>(short &arg) const { if (QDBusArgumentPrivate::checkReadAndDetach(d)) arg = d->demarshaller()->toShort(); + else + arg = 0; return *this; } @@ -653,6 +661,8 @@ const QDBusArgument &QDBusArgument::operator>>(int &arg) const { if (QDBusArgumentPrivate::checkReadAndDetach(d)) arg = d->demarshaller()->toInt(); + else + arg = 0; return *this; } @@ -665,6 +675,8 @@ const QDBusArgument &QDBusArgument::operator>>(uint &arg) const { if (QDBusArgumentPrivate::checkReadAndDetach(d)) arg = d->demarshaller()->toUInt(); + else + arg = 0; return *this; } @@ -677,6 +689,8 @@ const QDBusArgument &QDBusArgument::operator>>(qlonglong &arg) const { if (QDBusArgumentPrivate::checkReadAndDetach(d)) arg = d->demarshaller()->toLongLong(); + else + arg = 0; return *this; } @@ -689,6 +703,8 @@ const QDBusArgument &QDBusArgument::operator>>(qulonglong &arg) const { if (QDBusArgumentPrivate::checkReadAndDetach(d)) arg = d->demarshaller()->toULongLong(); + else + arg = 0; return *this; } @@ -701,6 +717,8 @@ const QDBusArgument &QDBusArgument::operator>>(double &arg) const { if (QDBusArgumentPrivate::checkReadAndDetach(d)) arg = d->demarshaller()->toDouble(); + else + arg = 0; return *this; }