diff mbox

vnc: Make ledstate comparison before modifiers updated

Message ID 1368606040-11950-1-git-send-email-lilei@linux.vnet.ibm.com
State New
Headers show

Commit Message

Lei Li May 15, 2013, 8:20 a.m. UTC
The ledstate should be compared before modifiers updated,
otherwise the ledstate would be the same as current_led_state.

Reported-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
---
 ui/vnc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Laszlo Ersek May 15, 2013, 8:31 a.m. UTC | #1
On 05/15/13 10:20, Lei Li wrote:
> The ledstate should be compared before modifiers updated,
> otherwise the ledstate would be the same as current_led_state.
> 
> Reported-by: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
> ---
>  ui/vnc.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/ui/vnc.c b/ui/vnc.c
> index 89108de..dfc7459 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -1601,6 +1601,7 @@ static void kbd_leds(void *opaque, int ledstate)
>  {
>      VncState *vs = opaque;
>      int caps, num, scr;
> +    bool has_changed = (ledstate != current_led_state(vs));
>  
>      caps = ledstate & QEMU_CAPS_LOCK_LED ? 1 : 0;
>      num  = ledstate & QEMU_NUM_LOCK_LED  ? 1 : 0;
> @@ -1617,7 +1618,7 @@ static void kbd_leds(void *opaque, int ledstate)
>      }
>  
>      /* Sending the current led state message to the client */
> -    if (ledstate != current_led_state(vs)) {
> +    if (has_changed) {
>          vnc_led_state_change(vs);
>      }
>  }
> 

Looks good to me.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Anthony Liguori May 16, 2013, 12:50 p.m. UTC | #2
Applied.  Thanks.

Regards,

Anthony Liguori
diff mbox

Patch

diff --git a/ui/vnc.c b/ui/vnc.c
index 89108de..dfc7459 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1601,6 +1601,7 @@  static void kbd_leds(void *opaque, int ledstate)
 {
     VncState *vs = opaque;
     int caps, num, scr;
+    bool has_changed = (ledstate != current_led_state(vs));
 
     caps = ledstate & QEMU_CAPS_LOCK_LED ? 1 : 0;
     num  = ledstate & QEMU_NUM_LOCK_LED  ? 1 : 0;
@@ -1617,7 +1618,7 @@  static void kbd_leds(void *opaque, int ledstate)
     }
 
     /* Sending the current led state message to the client */
-    if (ledstate != current_led_state(vs)) {
+    if (has_changed) {
         vnc_led_state_change(vs);
     }
 }