[Spice-devel,spice-server,v2] agent-msg-filter: use bool instead of gboolean

Submitted by Frediano Ziglio on June 16, 2017, 1:44 p.m.

Details

Message ID 20170616134459.12179-1-fziglio@redhat.com
State New
Headers show
Series "reds: Use bool for boolean types" ( rev: 6 5 4 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio June 16, 2017, 1:44 p.m.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/agent-msg-filter.c            | 10 +++++-----
 server/agent-msg-filter.h            | 19 ++++++++++---------
 server/reds.c                        | 20 ++++++++++----------
 server/tests/test-agent-msg-filter.c | 34 +++++++++++++++++-----------------
 4 files changed, 42 insertions(+), 41 deletions(-)

Changes since v1:
- don't use XXX == true or XXX == false in test.

Patch hide | download patch | download mbox

diff --git a/server/agent-msg-filter.c b/server/agent-msg-filter.c
index da6640c..fd627a6 100644
--- a/server/agent-msg-filter.c
+++ b/server/agent-msg-filter.c
@@ -27,8 +27,8 @@ 
 #include "agent-msg-filter.h"
 
 void agent_msg_filter_config(AgentMsgFilter *filter,
-                             gboolean copy_paste, gboolean file_xfer,
-                             gboolean use_client_monitors_config)
+                             bool copy_paste, bool file_xfer,
+                             bool use_client_monitors_config)
 {
     filter->copy_paste_enabled = copy_paste;
     filter->file_xfer_enabled = file_xfer;
@@ -36,9 +36,9 @@  void agent_msg_filter_config(AgentMsgFilter *filter,
 }
 
 void agent_msg_filter_init(AgentMsgFilter *filter,
-                           gboolean copy_paste, gboolean file_xfer,
-                           gboolean use_client_monitors_config,
-                           gboolean discard_all)
+                           bool copy_paste, bool file_xfer,
+                           bool use_client_monitors_config,
+                           bool discard_all)
 {
     memset(filter, 0, sizeof(*filter));
     agent_msg_filter_config(filter, copy_paste, file_xfer,
diff --git a/server/agent-msg-filter.h b/server/agent-msg-filter.h
index bd124ea..9aef2b9 100644
--- a/server/agent-msg-filter.h
+++ b/server/agent-msg-filter.h
@@ -22,6 +22,7 @@ 
 #define AGENT_MSG_FILTER_H_
 
 #include <inttypes.h>
+#include <stdbool.h>
 #include <glib.h>
 
 /* Possible return values for agent_msg_filter_process_data */
@@ -35,19 +36,19 @@  typedef enum {
 typedef struct AgentMsgFilter {
     int msg_data_to_read;
     AgentMsgFilterResult result;
-    gboolean copy_paste_enabled;
-    gboolean file_xfer_enabled;
-    gboolean use_client_monitors_config;
-    gboolean discard_all;
+    bool copy_paste_enabled;
+    bool file_xfer_enabled;
+    bool use_client_monitors_config;
+    bool discard_all;
 } AgentMsgFilter;
 
 void agent_msg_filter_init(AgentMsgFilter *filter,
-                           gboolean copy_paste, gboolean file_xfer,
-                           gboolean use_client_monitors_config,
-                           gboolean discard_all);
+                           bool copy_paste, bool file_xfer,
+                           bool use_client_monitors_config,
+                           bool discard_all);
 void agent_msg_filter_config(AgentMsgFilter *filter,
-                             gboolean copy_paste, gboolean file_xfer,
-                             gboolean use_client_monitors_config);
+                             bool copy_paste, bool file_xfer,
+                             bool use_client_monitors_config);
 AgentMsgFilterResult agent_msg_filter_process_data(AgentMsgFilter *filter,
                                                    const uint8_t *data, uint32_t len);
 
diff --git a/server/reds.c b/server/reds.c
index 532b121..59598e3 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -453,7 +453,7 @@  static void reds_reset_vdp(RedsState *reds)
     /* Reset read filter to start with clean state when the agent reconnects */
     agent_msg_filter_init(&dev->priv->read_filter, reds->config->agent_copypaste,
                           reds->config->agent_file_xfer,
-                          reds_use_client_monitors_config(reds), TRUE);
+                          reds_use_client_monitors_config(reds), true);
     /* Throw away pending chunks from the current (if any) and future
      * messages written by the client.
      * TODO: client should clear its agent messages queue when the agent
@@ -461,7 +461,7 @@  static void reds_reset_vdp(RedsState *reds)
      * messages that were directed to the previous instance of the agent continue
      * to be sent from the client. This TODO will require server, protocol, and client changes */
     dev->priv->write_filter.result = AGENT_MSG_FILTER_DISCARD;
-    dev->priv->write_filter.discard_all = TRUE;
+    dev->priv->write_filter.discard_all = true;
     dev->priv->client_agent_started = false;
 
     /*  The client's tokens are set once when the main channel is initialized
@@ -557,12 +557,12 @@  void reds_client_disconnect(RedsState *reds, RedClient *client)
         /* Reset write filter to start with clean state on client reconnect */
         agent_msg_filter_init(&reds->agent_dev->priv->write_filter, reds->config->agent_copypaste,
                               reds->config->agent_file_xfer,
-                              reds_use_client_monitors_config(reds), TRUE);
+                              reds_use_client_monitors_config(reds), true);
 
         /* Throw away pending chunks from the current (if any) and future
          *  messages read from the agent */
         reds->agent_dev->priv->read_filter.result = AGENT_MSG_FILTER_DISCARD;
-        reds->agent_dev->priv->read_filter.discard_all = TRUE;
+        reds->agent_dev->priv->read_filter.discard_all = true;
         free(reds->agent_dev->priv->mig_data);
         reds->agent_dev->priv->mig_data = NULL;
 
@@ -1038,7 +1038,7 @@  void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t
     agent_msg_filter_config(&reds->agent_dev->priv->write_filter, reds->config->agent_copypaste,
                             reds->config->agent_file_xfer,
                             reds_use_client_monitors_config(reds));
-    reds->agent_dev->priv->write_filter.discard_all = FALSE;
+    reds->agent_dev->priv->write_filter.discard_all = false;
 }
 
 void reds_on_main_agent_tokens(RedsState *reds, MainChannelClient *mcc, uint32_t num_tokens)
@@ -1370,7 +1370,7 @@  static int reds_agent_state_restore(RedsState *reds, SpiceMigrateDataMain *mig_d
             agent_dev->priv->read_filter.result = mig_data->agent2client.msg_filter_result;
     }
 
-    agent_dev->priv->read_filter.discard_all = FALSE;
+    agent_dev->priv->read_filter.discard_all = false;
     agent_dev->priv->write_filter.discard_all = !mig_data->client_agent_started;
     agent_dev->priv->client_agent_started = !!mig_data->client_agent_started;
 
@@ -1774,7 +1774,7 @@  static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
                                 reds->config->agent_copypaste,
                                 reds->config->agent_file_xfer,
                                 reds_use_client_monitors_config(reds));
-        reds->agent_dev->priv->read_filter.discard_all = FALSE;
+        reds->agent_dev->priv->read_filter.discard_all = false;
         reds->agent_dev->priv->plug_generation++;
     }
 
@@ -3055,7 +3055,7 @@  static RedCharDevice *attach_to_red_agent(RedsState *reds, SpiceCharDeviceInstan
         return RED_CHAR_DEVICE(dev);
     }
 
-    dev->priv->read_filter.discard_all = FALSE;
+    dev->priv->read_filter.discard_all = false;
     dev->priv->plug_generation++;
 
     if (dev->priv->mig_data ||
@@ -4470,11 +4470,11 @@  static void red_char_device_vdi_port_constructed(GObject *object)
     agent_msg_filter_init(&dev->priv->write_filter, reds->config->agent_copypaste,
                           reds->config->agent_file_xfer,
                           reds_use_client_monitors_config(reds),
-                          TRUE);
+                          true);
     agent_msg_filter_init(&dev->priv->read_filter, reds->config->agent_copypaste,
                           reds->config->agent_file_xfer,
                           reds_use_client_monitors_config(reds),
-                          TRUE);
+                          true);
 }
 
 static void
diff --git a/server/tests/test-agent-msg-filter.c b/server/tests/test-agent-msg-filter.c
index 2f5568a..64dbead 100644
--- a/server/tests/test-agent-msg-filter.c
+++ b/server/tests/test-agent-msg-filter.c
@@ -27,29 +27,29 @@  static void test_agent_msg_filter_setup(void)
     AgentMsgFilter filter = {
         .msg_data_to_read = 42,
         .result = AGENT_MSG_FILTER_PROTO_ERROR,
-        .copy_paste_enabled = FALSE,
-        .file_xfer_enabled = FALSE,
-        .use_client_monitors_config = FALSE,
-        .discard_all = TRUE,
+        .copy_paste_enabled = false,
+        .file_xfer_enabled = false,
+        .use_client_monitors_config = false,
+        .discard_all = true,
     };
 
     /* config doesn't change other fields */
-    agent_msg_filter_config(&filter, TRUE, TRUE, TRUE);
+    agent_msg_filter_config(&filter, true, true, true);
     g_assert_cmpint(filter.msg_data_to_read, ==, 42);
     g_assert_cmpint(filter.result, ==, AGENT_MSG_FILTER_PROTO_ERROR);
-    g_assert(filter.copy_paste_enabled == TRUE);
-    g_assert(filter.file_xfer_enabled == TRUE);
-    g_assert(filter.use_client_monitors_config == TRUE);
-    g_assert(filter.discard_all == TRUE);
+    g_assert(filter.copy_paste_enabled);
+    g_assert(filter.file_xfer_enabled);
+    g_assert(filter.use_client_monitors_config);
+    g_assert(filter.discard_all);
 
     /* init clears filter */
-    agent_msg_filter_init(&filter, FALSE, FALSE, FALSE, FALSE);
+    agent_msg_filter_init(&filter, false, false, false, false);
     g_assert_cmpint(filter.msg_data_to_read, ==, 0);
     g_assert_cmpint(filter.result, ==, AGENT_MSG_FILTER_OK);
-    g_assert(filter.copy_paste_enabled == FALSE);
-    g_assert(filter.file_xfer_enabled == FALSE);
-    g_assert(filter.use_client_monitors_config == FALSE);
-    g_assert(filter.discard_all == FALSE);
+    g_assert(!filter.copy_paste_enabled);
+    g_assert(!filter.file_xfer_enabled);
+    g_assert(!filter.use_client_monitors_config);
+    g_assert(!filter.discard_all);
 }
 
 static void test_agent_msg_filter_run(void)
@@ -61,7 +61,7 @@  static void test_agent_msg_filter_run(void)
     } msg;
     uint32_t len, type;
 
-    agent_msg_filter_init(&filter, TRUE, TRUE, TRUE, TRUE); /* discard all */
+    agent_msg_filter_init(&filter, true, true, true, true); /* discard all */
 
     /* message size too large */
     len = VD_AGENT_MAX_DATA_SIZE + 1;
@@ -96,7 +96,7 @@  static void test_agent_msg_filter_run(void)
     len = sizeof(msg.msg_header) + msg.msg_header.size; /* restore correct size */
 
     /* forward everything to the agent */
-    agent_msg_filter_init(&filter, TRUE, TRUE, FALSE, FALSE);
+    agent_msg_filter_init(&filter, true, true, false, false);
     for (type = VD_AGENT_MOUSE_STATE; type < VD_AGENT_END_MESSAGE; type++) {
         msg.msg_header.type = type;
         g_assert_cmpint(agent_msg_filter_process_data(&filter, msg.data, len), ==,
@@ -104,7 +104,7 @@  static void test_agent_msg_filter_run(void)
     }
 
     /* filter everything */
-    agent_msg_filter_config(&filter, FALSE, FALSE, TRUE);
+    agent_msg_filter_config(&filter, false, false, true);
     for (type = VD_AGENT_MOUSE_STATE; type < VD_AGENT_END_MESSAGE; type++) {
         AgentMsgFilterResult result;
         msg.msg_header.type = type;