Blame SOURCES/0039-Introduce-red_link_info_test_capability.patch

2be4b2
From 0b0ca2c972041b785145c558dfd0e8372869f696 Mon Sep 17 00:00:00 2001
2be4b2
From: Christophe Fergeau <cfergeau@redhat.com>
2be4b2
Date: Wed, 5 Mar 2014 11:59:37 +0100
2be4b2
Subject: [PATCH 2/3] Introduce red_link_info_test_capability()
2be4b2
2be4b2
This just hides a bit of pointer arithmetic away from reds_send_link_ack.
2be4b2
This helper will be used in the next commits.
2be4b2
---
2be4b2
 server/reds.c | 21 ++++++++++++++++++---
2be4b2
 1 file changed, 18 insertions(+), 3 deletions(-)
2be4b2
2be4b2
diff --git a/server/reds.c b/server/reds.c
2be4b2
index ccba67c..c1edf67 100644
2be4b2
--- a/server/reds.c
2be4b2
+++ b/server/reds.c
2be4b2
@@ -1446,6 +1446,22 @@ static void reds_channel_init_auth_caps(RedLinkInfo *link, RedChannel *channel)
2be4b2
     red_channel_set_common_cap(channel, SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
2be4b2
 }
2be4b2
 
2be4b2
+
2be4b2
+static const uint32_t *red_link_info_get_caps(const RedLinkInfo *link)
2be4b2
+{
2be4b2
+    const uint8_t *caps_start = (const uint8_t *)link->link_mess;
2be4b2
+
2be4b2
+    return (const uint32_t *)(caps_start + link->link_mess->caps_offset);
2be4b2
+}
2be4b2
+
2be4b2
+static bool red_link_info_test_capability(const RedLinkInfo *link, uint32_t cap)
2be4b2
+{
2be4b2
+    const uint32_t *caps = red_link_info_get_caps(link);
2be4b2
+
2be4b2
+    return test_capabilty(caps, link->link_mess->num_common_caps, cap);
2be4b2
+}
2be4b2
+
2be4b2
+
2be4b2
 static int reds_send_link_ack(RedLinkInfo *link)
2be4b2
 {
2be4b2
     SpiceLinkHeader header;
2be4b2
@@ -2701,7 +2717,6 @@ static void reds_handle_read_link_done(void *opaque)
2be4b2
     SpiceLinkMess *link_mess = link->link_mess;
2be4b2
     AsyncRead *obj = &link->asyc_read;
2be4b2
     uint32_t num_caps = link_mess->num_common_caps + link_mess->num_channel_caps;
2be4b2
-    uint32_t *caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset);
2be4b2
     int auth_selection;
2be4b2
 
2be4b2
     if (num_caps && (num_caps * sizeof(uint32_t) + link_mess->caps_offset >
2be4b2
@@ -2712,8 +2727,8 @@ static void reds_handle_read_link_done(void *opaque)
2be4b2
         return;
2be4b2
     }
2be4b2
 
2be4b2
-    auth_selection = test_capabilty(caps, link_mess->num_common_caps,
2be4b2
-                                    SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
2be4b2
+    auth_selection = red_link_info_test_capability(link,
2be4b2
+                                                   SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
2be4b2
 
2be4b2
     if (!reds_security_check(link)) {
2be4b2
         if (link->stream->ssl) {
2be4b2
-- 
2be4b2
2.4.4
2be4b2