[Spice-commits] 3 commits - server/inputs_channel.c

Christophe Fergau teuf at kemper.freedesktop.org
Mon Dec 22 03:44:20 PST 2014


 server/inputs_channel.c |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

New commits:
commit a19867e7137860efa6c2569b3da3845081698223
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Wed Dec 10 17:26:04 2014 +0100

    inputs: Remove unneeded variable
    
    inputs_channel_handle_parsed() is casting its void * argument to
    a uint8_t * buf before recasting this 'buf' variable to different
    other types. This intermediate 'buf' variable is not needed, especially
    as we can then benefit from implicit casts from void * to the type we
    need.

diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index 5059e98..b0ba1d6 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -325,13 +325,12 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
 {
     InputsChannel *inputs_channel = (InputsChannel *)rcc->channel;
     InputsChannelClient *icc = (InputsChannelClient *)rcc;
-    uint8_t *buf = (uint8_t *)message;
     uint32_t i;
 
     spice_assert(g_inputs_channel == inputs_channel);
     switch (type) {
     case SPICE_MSGC_INPUTS_KEY_DOWN: {
-        SpiceMsgcKeyDown *key_down = (SpiceMsgcKeyDown *)buf;
+        SpiceMsgcKeyDown *key_down = message;
         if (key_down->code == CAPS_LOCK_SCAN_CODE ||
             key_down->code == NUM_LOCK_SCAN_CODE ||
             key_down->code == SCROLL_LOCK_SCAN_CODE) {
@@ -339,7 +338,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
         }
     }
     case SPICE_MSGC_INPUTS_KEY_UP: {
-        SpiceMsgcKeyUp *key_up = (SpiceMsgcKeyUp *)buf;
+        SpiceMsgcKeyUp *key_up = message;
         for (i = 0; i < 4; i++) {
             uint8_t code = (key_up->code >> (i * 8)) & 0xff;
             if (code == 0) {
@@ -350,14 +349,14 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
         break;
     }
     case SPICE_MSGC_INPUTS_KEY_SCANCODE: {
-        uint8_t *code = (uint8_t *)buf;
+        uint8_t *code = message;
         for (i = 0; i < size; i++) {
             kbd_push_scan(keyboard, code[i]);
         }
         break;
     }
     case SPICE_MSGC_INPUTS_MOUSE_MOTION: {
-        SpiceMsgcMouseMotion *mouse_motion = (SpiceMsgcMouseMotion *)buf;
+        SpiceMsgcMouseMotion *mouse_motion = message;
 
         if (++icc->motion_count % SPICE_INPUT_MOTION_ACK_BUNCH == 0 &&
             !g_inputs_channel->src_during_migrate) {
@@ -374,7 +373,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
         break;
     }
     case SPICE_MSGC_INPUTS_MOUSE_POSITION: {
-        SpiceMsgcMousePosition *pos = (SpiceMsgcMousePosition *)buf;
+        SpiceMsgcMousePosition *pos = message;
 
         if (++icc->motion_count % SPICE_INPUT_MOTION_ACK_BUNCH == 0 &&
             !g_inputs_channel->src_during_migrate) {
@@ -400,7 +399,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
         break;
     }
     case SPICE_MSGC_INPUTS_MOUSE_PRESS: {
-        SpiceMsgcMousePress *mouse_press = (SpiceMsgcMousePress *)buf;
+        SpiceMsgcMousePress *mouse_press = message;
         int dz = 0;
         if (mouse_press->button == SPICE_MOUSE_BUTTON_UP) {
             dz = -1;
@@ -428,7 +427,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
         break;
     }
     case SPICE_MSGC_INPUTS_MOUSE_RELEASE: {
-        SpiceMsgcMouseRelease *mouse_release = (SpiceMsgcMouseRelease *)buf;
+        SpiceMsgcMouseRelease *mouse_release = message;
         if (reds_get_mouse_mode() == SPICE_MOUSE_MODE_CLIENT) {
             if (reds_get_agent_mouse() && reds_has_vdagent()) {
                 inputs_channel->mouse_state.buttons =
@@ -448,7 +447,7 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
         break;
     }
     case SPICE_MSGC_INPUTS_KEY_MODIFIERS: {
-        SpiceMsgcKeyModifiers *modifiers = (SpiceMsgcKeyModifiers *)buf;
+        SpiceMsgcKeyModifiers *modifiers = message;
         uint8_t leds;
 
         if (!keyboard) {
commit 0d35c3e9302308390262252e3a793d9431f31090
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Wed Dec 10 17:24:30 2014 +0100

    inputs: Split overlong line
    
    Cosmetic change.

diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index 3c64626..5059e98 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -332,7 +332,8 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
     switch (type) {
     case SPICE_MSGC_INPUTS_KEY_DOWN: {
         SpiceMsgcKeyDown *key_down = (SpiceMsgcKeyDown *)buf;
-        if (key_down->code == CAPS_LOCK_SCAN_CODE || key_down->code == NUM_LOCK_SCAN_CODE ||
+        if (key_down->code == CAPS_LOCK_SCAN_CODE ||
+            key_down->code == NUM_LOCK_SCAN_CODE ||
             key_down->code == SCROLL_LOCK_SCAN_CODE) {
             activate_modifiers_watch();
         }
commit 9f2145ac456f43ee52705beb58161c567773d816
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Wed Dec 10 17:22:57 2014 +0100

    inputs: Fix key_up/key_down mismatch
    
    When handling a KEY_UP message, the various variables were called
    'key_down', and they were called 'key_up' when handling KEY_DOWN
    messages. This commit makes the naming consistent.

diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index 395b81f..3c64626 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -331,16 +331,16 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
     spice_assert(g_inputs_channel == inputs_channel);
     switch (type) {
     case SPICE_MSGC_INPUTS_KEY_DOWN: {
-        SpiceMsgcKeyDown *key_up = (SpiceMsgcKeyDown *)buf;
-        if (key_up->code == CAPS_LOCK_SCAN_CODE || key_up->code == NUM_LOCK_SCAN_CODE ||
-            key_up->code == SCROLL_LOCK_SCAN_CODE) {
+        SpiceMsgcKeyDown *key_down = (SpiceMsgcKeyDown *)buf;
+        if (key_down->code == CAPS_LOCK_SCAN_CODE || key_down->code == NUM_LOCK_SCAN_CODE ||
+            key_down->code == SCROLL_LOCK_SCAN_CODE) {
             activate_modifiers_watch();
         }
     }
     case SPICE_MSGC_INPUTS_KEY_UP: {
-        SpiceMsgcKeyDown *key_down = (SpiceMsgcKeyDown *)buf;
+        SpiceMsgcKeyUp *key_up = (SpiceMsgcKeyUp *)buf;
         for (i = 0; i < 4; i++) {
-            uint8_t code = (key_down->code >> (i * 8)) & 0xff;
+            uint8_t code = (key_up->code >> (i * 8)) & 0xff;
             if (code == 0) {
                 break;
             }


More information about the Spice-commits mailing list