[Spice-devel] [PATCH 5/7] spice-ppc: avoid casts to lessers types!

Paolo Bonzini pbonzini at redhat.com
Thu Aug 9 07:54:32 PDT 2012


Il 07/08/2012 20:39, Erlon Cruz ha scritto:
> From: Fabiano Fidêncio <fabiano at fidencio.org>
> 
>     It's breaking PPC's keyboard functionality, once this cast is
>     getting the first byte (from left to right) on any architecture,
>     what's wrong when we think in a PPC (we should get the last one,
>     instead).
> 
> Signed-off-by: Erlon R. Cruz <erlon.cruz at br.flextronics.com>
> Signed-off-by: Fabiano Fidêncio <Fabiano.Fidêncio at fit-tecnologia.org.br>
> Signed-off-by: Rafael F. Santos <Rafael.Santos at fit-tecnologia.org.br>
> 
> ---
>  server/inputs_channel.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/server/inputs_channel.c b/server/inputs_channel.c
> index e14e995..015f7b5 100644
> --- a/server/inputs_channel.c
> +++ b/server/inputs_channel.c
> @@ -289,7 +289,7 @@ 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 *buf = message;
>  
>      spice_assert(g_inputs_channel == inputs_channel);
>      switch (type) {
> @@ -302,8 +302,8 @@ static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, ui
>      }
>      case SPICE_MSGC_INPUTS_KEY_UP: {
>          SpiceMsgcKeyDown *key_down = (SpiceMsgcKeyDown *)buf;
> -        uint8_t *now = (uint8_t *)&key_down->code;
> -        uint8_t *end = now + sizeof(key_down->code);
> +        uint32_t *now = &key_down->code;
> +        uint32_t *end = now + sizeof(key_down->code);
>          for (; now < end && *now; now++) {
>              kbd_push_scan(keyboard, *now);
>          }
> 

This looks weird... suddenly you're running the loop 1/4 of the
iterations that you used to.

It looks like the mistake is in the client here.

Paolo



More information about the Spice-devel mailing list