From: "Daniel P. Berrange" <berrange(a)redhat.com>
Coverity complains that the test suite did not check the
return value of dbus_message_iter_append_basic() as we did
in most other places.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
tests/virsystemdmock.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/tests/virsystemdmock.c b/tests/virsystemdmock.c
index 59b312d..b8fc031 100644
--- a/tests/virsystemdmock.c
+++ b/tests/virsystemdmock.c
@@ -82,10 +82,8 @@ DBusMessage *dbus_connection_send_with_reply_and_block(DBusConnection
*connectio
dbus_message_iter_init_append(reply, &iter);
if (!dbus_message_iter_append_basic(&iter,
DBUS_TYPE_STRING,
- &error_message)) {
- dbus_message_unref(reply);
- return NULL;
- }
+ &error_message))
+ goto error;
} else {
reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
}
@@ -98,19 +96,25 @@ DBusMessage *dbus_connection_send_with_reply_and_block(DBusConnection
*connectio
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
"s", &sub);
- dbus_message_iter_append_basic(&sub,
+ if (!dbus_message_iter_append_basic(&sub,
DBUS_TYPE_STRING,
- &svc1);
- if (!getenv("FAIL_NO_SERVICE"))
- dbus_message_iter_append_basic(&sub,
- DBUS_TYPE_STRING,
- &svc2);
+ &svc1))
+ goto error;
+ if (!getenv("FAIL_NO_SERVICE") &&
+ !dbus_message_iter_append_basic(&sub,
+ DBUS_TYPE_STRING,
+ &svc2))
+ goto error;
dbus_message_iter_close_container(&iter, &sub);
} else {
reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
}
return reply;
+
+ error:
+ dbus_message_unref(reply);
+ return NULL;
}
#else
--
1.8.3.1
Show replies by date
On 09/20/2013 06:48 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Coverity complains that the test suite did not check the
return value of dbus_message_iter_append_basic() as we did
in most other places.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
tests/virsystemdmock.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
ACK
John