[Spice-devel] [PATCH spice-server 6/8] agent-msg-filter: Simplify code

Frediano Ziglio fziglio at redhat.com
Mon Feb 11 11:54:43 UTC 2019


Most of the time result is set to AGENT_MSG_FILTER_OK, set at
the beginning and change if necessary.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/agent-msg-filter.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/server/agent-msg-filter.c b/server/agent-msg-filter.c
index 458f563b7..abead87a5 100644
--- a/server/agent-msg-filter.c
+++ b/server/agent-msg-filter.c
@@ -82,35 +82,31 @@ data_to_read:
     if (filter->discard_all) {
         filter->result = AGENT_MSG_FILTER_DISCARD;
     } else {
+        // default, easier to set once
+        filter->result = AGENT_MSG_FILTER_OK;
         switch (msg_header.type) {
         case VD_AGENT_CLIPBOARD:
         case VD_AGENT_CLIPBOARD_GRAB:
         case VD_AGENT_CLIPBOARD_REQUEST:
         case VD_AGENT_CLIPBOARD_RELEASE:
-            if (filter->copy_paste_enabled) {
-                filter->result = AGENT_MSG_FILTER_OK;
-            } else {
+            if (!filter->copy_paste_enabled) {
                 filter->result = AGENT_MSG_FILTER_DISCARD;
             }
             break;
         case VD_AGENT_FILE_XFER_START:
         case VD_AGENT_FILE_XFER_STATUS:
         case VD_AGENT_FILE_XFER_DATA:
-            if (filter->file_xfer_enabled) {
-                filter->result = AGENT_MSG_FILTER_OK;
-            } else {
+            if (!filter->file_xfer_enabled) {
                 filter->result = AGENT_MSG_FILTER_DISCARD;
             }
             break;
         case VD_AGENT_MONITORS_CONFIG:
             if (filter->use_client_monitors_config) {
                 filter->result = AGENT_MSG_FILTER_MONITORS_CONFIG;
-            } else {
-                filter->result = AGENT_MSG_FILTER_OK;
             }
             break;
         default:
-            filter->result = AGENT_MSG_FILTER_OK;
+            break;
         }
     }
 
-- 
2.20.1



More information about the Spice-devel mailing list