[spice-server 3/4] Replace remaining spice_printerr() with g_warning()

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

 



The remaining occurrences of spice_printerr() are warnings when
something unexpected happens, they can be replaced with g_warning() so
that users of spice-server can redirect them with
g_log_set_default_handler().
---
 server/agent-msg-filter.c   |  8 ++++----
 server/char-device.c        |  8 ++++----
 server/dispatcher.c         | 22 +++++++++++-----------
 server/net-utils.c          |  4 ++--
 server/red-channel-client.c |  2 +-
 server/red-replay-qxl.c     |  9 ++++-----
 server/red-stream-device.c  |  2 +-
 server/zlib-encoder.c       |  2 +-
 8 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/server/agent-msg-filter.c b/server/agent-msg-filter.c
index da6640c58..458f563b7 100644
--- a/server/agent-msg-filter.c
+++ b/server/agent-msg-filter.c
@@ -52,7 +52,7 @@ AgentMsgFilterResult agent_msg_filter_process_data(AgentMsgFilter *filter,
     struct VDAgentMessage msg_header;
 
     if (len > VD_AGENT_MAX_DATA_SIZE) {
-        spice_printerr("invalid agent message: too large");
+        g_warning("invalid agent message: too large");
         return AGENT_MSG_FILTER_PROTO_ERROR;
     }
 
@@ -60,7 +60,7 @@ AgentMsgFilterResult agent_msg_filter_process_data(AgentMsgFilter *filter,
     if (filter->msg_data_to_read) {
 data_to_read:
         if (len > filter->msg_data_to_read) {
-            spice_printerr("invalid agent message: data exceeds size from header");
+            g_warning("invalid agent message: data exceeds size from header");
             return AGENT_MSG_FILTER_PROTO_ERROR;
         }
         filter->msg_data_to_read -= len;
@@ -68,14 +68,14 @@ data_to_read:
     }
 
     if (len < sizeof(msg_header)) {
-        spice_printerr("invalid agent message: incomplete header");
+        g_warning("invalid agent message: incomplete header");
         return AGENT_MSG_FILTER_PROTO_ERROR;
     }
     memcpy(&msg_header, data, sizeof(msg_header));
     len -= sizeof(msg_header);
 
     if (msg_header.protocol != VD_AGENT_PROTOCOL) {
-        spice_printerr("invalid agent protocol: %u", msg_header.protocol);
+        g_warning("invalid agent protocol: %u", msg_header.protocol);
         return AGENT_MSG_FILTER_PROTO_ERROR;
     }
 
diff --git a/server/char-device.c b/server/char-device.c
index 2b34e4020..ae538fab1 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -568,7 +568,7 @@ static RedCharDeviceWriteBuffer *__red_char_device_write_buffer_get(
        if (dev_client) {
             if (!migrated_data_tokens &&
                 dev_client->do_flow_control && !dev_client->num_client_tokens) {
-                spice_printerr("token violation: dev %p client %p", dev, client);
+                g_warning("token violation: dev %p client %p", dev, client);
                 red_char_device_handle_client_overflow(dev_client);
                 goto error;
             }
@@ -579,7 +579,7 @@ static RedCharDeviceWriteBuffer *__red_char_device_write_buffer_get(
         } else {
             /* it is possible that the client was removed due to send tokens underflow, but
              * the caller still receive messages from the client */
-            spice_printerr("client not found: dev %p client %p", dev, client);
+            g_warning("client not found: dev %p client %p", dev, client);
             goto error;
         }
     } else if (origin == WRITE_BUFFER_ORIGIN_SERVER) {
@@ -635,7 +635,7 @@ void red_char_device_write_buffer_add(RedCharDevice *dev,
     /* caller shouldn't add buffers for client that was removed */
     if (write_buf->priv->origin == WRITE_BUFFER_ORIGIN_CLIENT &&
         !red_char_device_client_find(dev, write_buf->priv->client)) {
-        spice_printerr("client not found: dev %p client %p", dev, write_buf->priv->client);
+        g_warning("client not found: dev %p client %p", dev, write_buf->priv->client);
         red_char_device_write_buffer_pool_add(dev, write_buf);
         return;
     }
@@ -658,7 +658,7 @@ void red_char_device_write_buffer_release(RedCharDevice *dev,
     RedClient *client = write_buf->priv->client;
 
     if (!dev) {
-        spice_printerr("no device. write buffer is freed");
+        g_warning("no device. write buffer is freed");
         red_char_device_write_buffer_free(write_buf);
         return;
     }
diff --git a/server/dispatcher.c b/server/dispatcher.c
index 3e0decde5..0953db875 100644
--- a/server/dispatcher.c
+++ b/server/dispatcher.c
@@ -259,7 +259,7 @@ static int dispatcher_handle_single_read(Dispatcher *dispatcher)
     uint32_t ack = ACK;
 
     if ((ret = read_safe(dispatcher->priv->recv_fd, (uint8_t*)&type, sizeof(type), 0)) == -1) {
-        spice_printerr("error reading from dispatcher: %d", errno);
+        g_warning("error reading from dispatcher: %d", errno);
         return 0;
     }
     if (ret == 0) {
@@ -272,7 +272,7 @@ static int dispatcher_handle_single_read(Dispatcher *dispatcher)
     }
     msg = &dispatcher->priv->messages[type];
     if (read_safe(dispatcher->priv->recv_fd, payload, msg->size, 1) == -1) {
-        spice_printerr("error reading from dispatcher: %d", errno);
+        g_warning("error reading from dispatcher: %d", errno);
         /* TODO: close socketpair? */
         return 0;
     }
@@ -282,12 +282,12 @@ static int dispatcher_handle_single_read(Dispatcher *dispatcher)
     if (msg->handler) {
         msg->handler(dispatcher->priv->opaque, payload);
     } else {
-        spice_printerr("error: no handler for message type %d", type);
+        g_warning("error: no handler for message type %d", type);
     }
     if (msg->ack) {
         if (write_safe(dispatcher->priv->recv_fd,
                        (uint8_t*)&ack, sizeof(ack)) == -1) {
-            spice_printerr("error writing ack for message %d", type);
+            g_warning("error writing ack for message %d", type);
             /* TODO: close socketpair? */
         }
     }
@@ -316,21 +316,21 @@ void dispatcher_send_message(Dispatcher *dispatcher, uint32_t message_type,
     msg = &dispatcher->priv->messages[message_type];
     pthread_mutex_lock(&dispatcher->priv->lock);
     if (write_safe(send_fd, (uint8_t*)&message_type, sizeof(message_type)) == -1) {
-        spice_printerr("error: failed to send message type for message %d",
-                   message_type);
+        g_warning("error: failed to send message type for message %d",
+                  message_type);
         goto unlock;
     }
     if (write_safe(send_fd, payload, msg->size) == -1) {
-        spice_printerr("error: failed to send message body for message %d",
-                   message_type);
+        g_warning("error: failed to send message body for message %d",
+                  message_type);
         goto unlock;
     }
     if (msg->ack) {
         if (read_safe(send_fd, (uint8_t*)&ack, sizeof(ack), 1) == -1) {
-            spice_printerr("error: failed to read ack");
+            g_warning("error: failed to read ack");
         } else if (ack != ACK) {
-            spice_printerr("error: got wrong ack value in dispatcher "
-                       "for message %d\n", message_type);
+            g_warning("error: got wrong ack value in dispatcher "
+                      "for message %d\n", message_type);
             /* TODO handling error? */
         }
     }
diff --git a/server/net-utils.c b/server/net-utils.c
index 90dbbed57..ca8a4e7f7 100644
--- a/server/net-utils.c
+++ b/server/net-utils.c
@@ -47,7 +47,7 @@ bool red_socket_set_keepalive(int fd, bool enable, int timeout)
 
     if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(keepalive)) == -1) {
         if (errno != ENOTSUP) {
-            spice_printerr("setsockopt for keepalive failed, %s", strerror(errno));
+            g_warning("setsockopt for keepalive failed, %s", strerror(errno));
             return false;
         }
     }
@@ -59,7 +59,7 @@ bool red_socket_set_keepalive(int fd, bool enable, int timeout)
 #ifdef HAVE_TCP_KEEPIDLE
     if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &timeout, sizeof(timeout)) == -1) {
         if (errno != ENOTSUP) {
-            spice_printerr("setsockopt for keepalive timeout failed, %s", strerror(errno));
+            g_warning("setsockopt for keepalive timeout failed, %s", strerror(errno));
             return false;
         }
     }
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 92880fc5f..b3a6ec12b 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1144,7 +1144,7 @@ static int red_peer_receive(RedStream *stream, uint8_t *buf, uint32_t size)
             } else if (errno == EPIPE) {
                 return -1;
             } else {
-                spice_printerr("%s", strerror(errno));
+                g_warning("%s", strerror(errno));
                 return -1;
             }
         } else {
diff --git a/server/red-replay-qxl.c b/server/red-replay-qxl.c
index a23296cf1..1fce76cb0 100644
--- a/server/red-replay-qxl.c
+++ b/server/red-replay-qxl.c
@@ -475,7 +475,7 @@ static QXLImage *red_replay_image(SpiceReplay *replay, uint32_t flags)
         } else {
             size = red_replay_data_chunks(replay, "bitmap.data", (uint8_t**)&qxl->bitmap.data, 0);
             if (size != bitmap_size) {
-                spice_printerr("bad image, %" PRIuPTR " != %" PRIuPTR, size, bitmap_size);
+                g_warning("bad image, %" PRIuPTR " != %" PRIuPTR, size, bitmap_size);
                 return NULL;
             }
         }
@@ -1137,7 +1137,7 @@ static QXLSurfaceCmd *red_replay_surface_cmd(SpiceReplay *replay)
         if ((qxl->flags & QXL_SURF_FLAG_KEEP_DATA) != 0) {
             read_binary(replay, "data", &read_size, (uint8_t**)&qxl->u.surface_create.data, 0);
             if (read_size != size) {
-                spice_printerr("mismatch %" PRIuPTR " != %" PRIuPTR, size, read_size);
+                g_warning("mismatch %" PRIuPTR " != %" PRIuPTR, size, read_size);
             }
         } else {
             qxl->u.surface_create.data = QXLPHYSICAL_FROM_PTR(replay_malloc(replay, size));
@@ -1240,9 +1240,8 @@ static void replay_handle_create_primary(QXLWorker *worker, SpiceReplay *replay)
     uint8_t *mem = NULL;
 
     if (replay->created_primary) {
-        spice_printerr(
-            "WARNING: %d: original recording event not preceded by a destroy primary",
-            replay->counter);
+        g_warning("WARNING: %d: original recording event not preceded by a destroy primary",
+                  replay->counter);
         worker->destroy_primary_surface(worker, 0);
     }
     replay->created_primary = TRUE;
diff --git a/server/red-stream-device.c b/server/red-stream-device.c
index 71b1b83b2..f280a089f 100644
--- a/server/red-stream-device.c
+++ b/server/red-stream-device.c
@@ -469,7 +469,7 @@ stream_device_send_msg_to_client(RedCharDevice *self, RedPipeItem *msg, RedClien
 static void
 stream_device_send_tokens_to_client(RedCharDevice *self, RedClient *client, uint32_t tokens)
 {
-    spice_printerr("Not implemented!");
+    g_warning("%s: Not implemented!", G_STRFUNC);
 }
 
 static void
diff --git a/server/zlib-encoder.c b/server/zlib-encoder.c
index 7b98abbb3..6042cffd5 100644
--- a/server/zlib-encoder.c
+++ b/server/zlib-encoder.c
@@ -51,7 +51,7 @@ ZlibEncoder* zlib_encoder_create(ZlibEncoderUsrContext *usr, int level)
     z_ret = deflateInit(&enc->strm, level);
     enc->last_level = level;
     if (z_ret != Z_OK) {
-        spice_printerr("zlib error");
+        g_warning("zlib error");
         g_free(enc);
         return NULL;
     }
-- 
2.17.1

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




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