[vdagent-linux 1/3] Add g_return_if_fail() guards to file xfer public functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With the next commit, we won't always have a file xfer object available.
This next commit will make sure NULL is never passed to the public file
xfer functions, but it's safer to guard against that anyway in case
this gets broken in the future.
---
 src/vdagent-file-xfers.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/vdagent-file-xfers.c b/src/vdagent-file-xfers.c
index b792282..379cda0 100644
--- a/src/vdagent-file-xfers.c
+++ b/src/vdagent-file-xfers.c
@@ -97,6 +97,8 @@ struct vdagent_file_xfers *vdagent_file_xfers_create(
 
 void vdagent_file_xfers_destroy(struct vdagent_file_xfers *xfers)
 {
+    g_return_if_fail(xfers != NULL);
+
     g_hash_table_destroy(xfers->xfers);
     g_free(xfers->save_dir);
     g_free(xfers);
@@ -107,6 +109,8 @@ AgentFileXferTask *vdagent_file_xfers_get_task(
 {
     AgentFileXferTask *task;
 
+    g_return_val_if_fail(xfers != NULL, NULL);
+
     task = g_hash_table_lookup(xfers->xfers, GUINT_TO_POINTER(id));
     if (task == NULL)
         syslog(LOG_ERR, "file-xfer: error can not find task %u", id);
@@ -173,6 +177,8 @@ void vdagent_file_xfers_start(struct vdagent_file_xfers *xfers,
     struct stat st;
     int i;
 
+    g_return_if_fail(xfers != NULL);
+
     if (g_hash_table_lookup(xfers->xfers, GUINT_TO_POINTER(msg->id))) {
         syslog(LOG_ERR, "file-xfer: error id %u already exists, ignoring!",
                msg->id);
@@ -246,6 +252,8 @@ void vdagent_file_xfers_status(struct vdagent_file_xfers *xfers,
 {
     AgentFileXferTask *task;
 
+    g_return_if_fail(xfers != NULL);
+
     task = vdagent_file_xfers_get_task(xfers, msg->id);
     if (!task)
         return;
@@ -267,6 +275,8 @@ void vdagent_file_xfers_data(struct vdagent_file_xfers *xfers,
     AgentFileXferTask *task;
     int len, status = -1;
 
+    g_return_if_fail(xfers != NULL);
+
     task = vdagent_file_xfers_get_task(xfers, msg->id);
     if (!task)
         return;
-- 
1.9.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]