[Spice-commits] 4 commits - server/cache-item.h server/cache-item.tmpl.c server/cursor-channel.c server/dcc-send.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Wed May 25 08:54:36 UTC 2016


 server/cache-item.h      |    3 +--
 server/cache-item.tmpl.c |   12 ++----------
 server/cursor-channel.c  |    4 ++--
 server/dcc-send.c        |    4 ++--
 4 files changed, 7 insertions(+), 16 deletions(-)

New commits:
commit 727d808332c471f304cc450f2c4680bc83a4a79f
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue May 24 15:49:01 2016 +0100

    Remove potentially unsafe casts
    
    The id type is already uint64_t, no need to cast using some low
    level casts.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index b4c2d3d..ab6864c 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -307,7 +307,7 @@ static inline void red_marshall_inval(RedChannelClient *rcc,
     SpiceMsgDisplayInvalOne inval_one;
 
     red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INVAL_ONE, NULL);
-    inval_one.id = *(uint64_t *)&cach_item->id;
+    inval_one.id = cach_item->id;
 
     spice_marshall_msg_cursor_inval_one(base_marshaller, &inval_one);
 }
diff --git a/server/dcc-send.c b/server/dcc-send.c
index d766e77..5171f9a 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -1777,7 +1777,7 @@ static inline void marshall_inval_palette(RedChannelClient *rcc,
     SpiceMsgDisplayInvalOne inval_one;
 
     red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_PALETTE, NULL);
-    inval_one.id = *(uint64_t *)&cache_item->id;
+    inval_one.id = cache_item->id;
 
     spice_marshall_msg_display_inval_palette(base_marshaller, &inval_one);
 
commit b921e81f76f832a1f6c044ec2721c7a9dc391075
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue May 24 15:39:06 2016 +0100

    Remove unused macro definitions
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/cache-item.tmpl.c b/server/cache-item.tmpl.c
index 9a9181c..2e6f5ca 100644
--- a/server/cache-item.tmpl.c
+++ b/server/cache-item.tmpl.c
@@ -44,8 +44,6 @@
 
 #endif
 
-#define CHANNEL_FROM_RCC(rcc) SPICE_CONTAINEROF((rcc)->channel, CHANNEL, common.base);
-
 static RedCacheItem *FUNC_NAME(find)(CHANNELCLIENT *channel_client, uint64_t id)
 {
     RedCacheItem *item = channel_client->CACHE_NAME[CACHE_HASH_KEY(id)];
@@ -131,9 +129,7 @@ static void FUNC_NAME(reset)(CHANNELCLIENT *channel_client, long size)
 #undef CACHE_NAME
 #undef CACHE_HASH_KEY
 #undef CACHE_HASH_SIZE
-#undef CACHE_MAX_CLIENT_SIZE
 #undef FUNC_NAME
 #undef VAR_NAME
 #undef CHANNEL
 #undef CHANNELCLIENT
-#undef CHANNEL_FROM_RCC
commit 6ab857b45c9848233ba9ca878ed9792825933e4a
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue May 24 15:36:19 2016 +0100

    Move RedCacheItem size field inside cache_data union
    
    This reduce a bit the structure size and make clear that
    the field is used only when the item is a cache item.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/cache-item.h b/server/cache-item.h
index 1dd2e71..58af7ba 100644
--- a/server/cache-item.h
+++ b/server/cache-item.h
@@ -30,10 +30,10 @@ struct RedCacheItem {
         struct {
             RingItem lru_link;
             RedCacheItem *next;
+            size_t size;
         } cache_data;
     } u;
     uint64_t id;
-    size_t size;
 };
 
 #endif /* CACHE_ITEM_H_ */
diff --git a/server/cache-item.tmpl.c b/server/cache-item.tmpl.c
index 2cf12d8..9a9181c 100644
--- a/server/cache-item.tmpl.c
+++ b/server/cache-item.tmpl.c
@@ -77,7 +77,7 @@ static void FUNC_NAME(remove)(CHANNELCLIENT *channel_client, RedCacheItem *item)
     }
     ring_remove(&item->u.cache_data.lru_link);
     channel_client->VAR_NAME(items)--;
-    channel_client->VAR_NAME(available) += item->size;
+    channel_client->VAR_NAME(available) += item->u.cache_data.size;
 
     red_pipe_item_init(&item->u.pipe_data, RED_PIPE_ITEM_TYPE_INVAL_ONE);
     red_channel_client_pipe_add_tail_and_push(&channel_client->common.base, &item->u.pipe_data); // for now
@@ -107,7 +107,7 @@ static int FUNC_NAME(add)(CHANNELCLIENT *channel_client, uint64_t id, size_t siz
     ring_item_init(&item->u.cache_data.lru_link);
     ring_add(&channel_client->VAR_NAME(lru), &item->u.cache_data.lru_link);
     item->id = id;
-    item->size = size;
+    item->u.cache_data.size = size;
     return TRUE;
 }
 
commit 68d5ca29f87f85437886603bd2193c6da8bacde1
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue May 24 15:30:28 2016 +0100

    Remove not necessary inval_type from RedCacheItem
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/cache-item.h b/server/cache-item.h
index fb19893..1dd2e71 100644
--- a/server/cache-item.h
+++ b/server/cache-item.h
@@ -34,7 +34,6 @@ struct RedCacheItem {
     } u;
     uint64_t id;
     size_t size;
-    uint32_t inval_type;
 };
 
 #endif /* CACHE_ITEM_H_ */
diff --git a/server/cache-item.tmpl.c b/server/cache-item.tmpl.c
index 0f22b35..2cf12d8 100644
--- a/server/cache-item.tmpl.c
+++ b/server/cache-item.tmpl.c
@@ -24,7 +24,6 @@
 #define CACHE_NAME cursor_cache
 #define CACHE_HASH_KEY CURSOR_CACHE_HASH_KEY
 #define CACHE_HASH_SIZE CURSOR_CACHE_HASH_SIZE
-#define CACHE_INVAL_TYPE SPICE_MSG_CURSOR_INVAL_ONE
 #define FUNC_NAME(name) red_cursor_cache_##name
 #define VAR_NAME(name) cursor_cache_##name
 #define CHANNEL CursorChannel
@@ -35,7 +34,6 @@
 #define CACHE_NAME palette_cache
 #define CACHE_HASH_KEY PALETTE_CACHE_HASH_KEY
 #define CACHE_HASH_SIZE PALETTE_CACHE_HASH_SIZE
-#define CACHE_INVAL_TYPE SPICE_MSG_DISPLAY_INVAL_PALETTE
 #define FUNC_NAME(name) red_palette_cache_##name
 #define VAR_NAME(name) palette_cache_##name
 #define CHANNEL DisplayChannel
@@ -110,7 +108,6 @@ static int FUNC_NAME(add)(CHANNELCLIENT *channel_client, uint64_t id, size_t siz
     ring_add(&channel_client->VAR_NAME(lru), &item->u.cache_data.lru_link);
     item->id = id;
     item->size = size;
-    item->inval_type = CACHE_INVAL_TYPE;
     return TRUE;
 }
 
@@ -134,7 +131,6 @@ static void FUNC_NAME(reset)(CHANNELCLIENT *channel_client, long size)
 #undef CACHE_NAME
 #undef CACHE_HASH_KEY
 #undef CACHE_HASH_SIZE
-#undef CACHE_INVAL_TYPE
 #undef CACHE_MAX_CLIENT_SIZE
 #undef FUNC_NAME
 #undef VAR_NAME
diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index 2869b11..b4c2d3d 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -306,7 +306,7 @@ static inline void red_marshall_inval(RedChannelClient *rcc,
 {
     SpiceMsgDisplayInvalOne inval_one;
 
-    red_channel_client_init_send_data(rcc, cach_item->inval_type, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INVAL_ONE, NULL);
     inval_one.id = *(uint64_t *)&cach_item->id;
 
     spice_marshall_msg_cursor_inval_one(base_marshaller, &inval_one);
diff --git a/server/dcc-send.c b/server/dcc-send.c
index 2b8da3d..d766e77 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -1776,7 +1776,7 @@ static inline void marshall_inval_palette(RedChannelClient *rcc,
 {
     SpiceMsgDisplayInvalOne inval_one;
 
-    red_channel_client_init_send_data(rcc, cache_item->inval_type, NULL);
+    red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_INVAL_PALETTE, NULL);
     inval_one.id = *(uint64_t *)&cache_item->id;
 
     spice_marshall_msg_display_inval_palette(base_marshaller, &inval_one);


More information about the Spice-commits mailing list