[PATCH] Change some asserts to warnings

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

 



From: Marc-André Lureau <marcandre.lureau@xxxxxxxxx>

Various changes in RedWorker and CursorChannel related to error and
warning messages.

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 server/cursor-channel.c | 28 ++++++++++++++++++++--------
 server/red_worker.c     | 17 +++++++----------
 server/red_worker.h     |  1 -
 3 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index ce360e1..5995aa5 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -212,7 +212,8 @@ void cursor_channel_disconnect(CursorChannel *cursor_channel)
 
 static void put_cursor_pipe_item(CursorChannelClient *ccc, CursorPipeItem *pipe_item)
 {
-    spice_assert(pipe_item);
+    spice_return_if_fail(pipe_item);
+    spice_return_if_fail(pipe_item->refs > 0);
 
     if (--pipe_item->refs) {
         return;
@@ -299,7 +300,7 @@ static void cursor_marshall(RedChannelClient *rcc,
     PipeItem *pipe_item = &cursor_pipe_item->base;
     RedCursorCmd *cmd;
 
-    spice_assert(cursor_channel);
+    spice_return_if_fail(cursor_channel);
 
     cmd = item->red_cursor;
     switch (cmd->type) {
@@ -387,7 +388,9 @@ static void cursor_channel_send_item(RedChannelClient *rcc, PipeItem *pipe_item)
 
 static CursorPipeItem *cursor_pipe_item_ref(CursorPipeItem *item)
 {
-    spice_assert(item);
+    spice_return_val_if_fail(item, NULL);
+    spice_return_val_if_fail(item->refs > 0, NULL);
+
     item->refs++;
     return item;
 }
@@ -396,7 +399,9 @@ static CursorPipeItem *cursor_pipe_item_ref(CursorPipeItem *item)
 static void cursor_channel_hold_pipe_item(RedChannelClient *rcc, PipeItem *item)
 {
     CursorPipeItem *cursor_pipe_item;
-    spice_assert(item);
+
+    spice_return_if_fail(item);
+
     cursor_pipe_item = SPICE_CONTAINEROF(item, CursorPipeItem, base);
     cursor_pipe_item_ref(cursor_pipe_item);
 }
@@ -454,6 +459,12 @@ CursorChannelClient* cursor_channel_client_new(CursorChannel *cursor, RedClient
                                                uint32_t *common_caps, int num_common_caps,
                                                uint32_t *caps, int num_caps)
 {
+    spice_return_val_if_fail(cursor, NULL);
+    spice_return_val_if_fail(client, NULL);
+    spice_return_val_if_fail(stream, NULL);
+    spice_return_val_if_fail(!num_common_caps || common_caps, NULL);
+    spice_return_val_if_fail(!num_caps || caps, NULL);
+
     CursorChannelClient *ccc =
         (CursorChannelClient*)common_channel_new_client(&cursor->common,
                                                         sizeof(CursorChannelClient),
@@ -464,11 +475,11 @@ CursorChannelClient* cursor_channel_client_new(CursorChannel *cursor, RedClient
                                                         num_common_caps,
                                                         caps,
                                                         num_caps);
-    if (!ccc) {
-        return NULL;
-    }
+    spice_return_val_if_fail(ccc != NULL, NULL);
+
     ring_init(&ccc->cursor_cache_lru);
     ccc->cursor_cache_available = CLIENT_CURSOR_CACHE_SIZE;
+
     return ccc;
 }
 
@@ -502,7 +513,8 @@ void cursor_channel_process_cmd(CursorChannel *cursor, RedCursorCmd *cursor_cmd,
         cursor->cursor_trail_frequency = cursor_cmd->u.trail.frequency;
         break;
     default:
-        spice_error("invalid cursor command %u", cursor_cmd->type);
+        spice_warning("invalid cursor command %u", cursor_cmd->type);
+        return;
     }
 
     if (red_channel_is_connected(&cursor->common.base) &&
diff --git a/server/red_worker.c b/server/red_worker.c
index 9702652..3853847 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -3972,7 +3972,7 @@ static int red_process_cursor(RedWorker *worker, uint32_t max_pipe_size, int *ri
             break;
         }
         default:
-            spice_error("bad command type");
+            spice_warning("bad command type");
         }
         n++;
     }
@@ -9537,19 +9537,15 @@ static void red_connect_cursor(RedWorker *worker, RedClient *client, RedsStream
     CursorChannel *channel;
     CursorChannelClient *ccc;
 
-    if (worker->cursor_channel == NULL) {
-        spice_warning("cursor channel was not created");
-        return;
-    }
+    spice_return_if_fail(worker->cursor_channel != NULL);
+
     channel = worker->cursor_channel;
     spice_info("add cursor channel client");
     ccc = cursor_channel_client_new(channel, client, stream,
                                     migrate,
                                     common_caps, num_common_caps,
                                     caps, num_caps);
-    if (!ccc) {
-        return;
-    }
+    spice_return_if_fail(ccc != NULL);
 
     RedChannelClient *rcc = RED_CHANNEL_CLIENT(ccc);
     red_channel_client_ack_zero_messages_window(rcc);
@@ -10245,9 +10241,10 @@ void handle_dev_cursor_channel_create(void *opaque, void *payload)
     RedWorker *worker = opaque;
     RedChannel *red_channel;
 
-    // TODO: handle seemless migration. Temp, setting migrate to FALSE
     if (!worker->cursor_channel) {
         worker->cursor_channel = cursor_channel_new(worker);
+    } else {
+        spice_warning("cursor channel already created");
     }
 
     red_channel = RED_CHANNEL(worker->cursor_channel);
@@ -10276,7 +10273,7 @@ void handle_dev_cursor_disconnect(void *opaque, void *payload)
     RedChannelClient *rcc = msg->rcc;
 
     spice_info("disconnect cursor client");
-    spice_assert(rcc);
+    spice_return_if_fail(rcc);
     red_channel_client_disconnect(rcc);
 }
 
diff --git a/server/red_worker.h b/server/red_worker.h
index d7a94fd..33dd974 100644
--- a/server/red_worker.h
+++ b/server/red_worker.h
@@ -66,7 +66,6 @@ typedef struct VerbItem {
 
 static inline void red_marshall_verb(RedChannelClient *rcc, VerbItem *item)
 {
-    spice_assert(rcc);
     red_channel_client_init_send_data(rcc, item->verb, NULL);
 }
 
-- 
2.5.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]