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

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

 



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@xxxxxxxxxx>
---
 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

_______________________________________________
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]