Re: [PATCH server 2/7] style, indentation and casts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> Hi Snir,
> 
> I would prefer if this and some other patches (3, 4) were squashed into your
> patch. Frediano, what do you think ?
> 
> Pavel
> 

Yes, my fault, these patches were meant to be squashed into, obviously if
agreed with them.

Frediano

> On Sun, 2016-05-29 at 17:30 +0300, Snir Sheriber wrote:
> > From: Frediano Ziglio <fziglio@xxxxxxxxxx>
> > 
> > ---
> >  server/spicevmc.c | 85
> >  ++++++++++++++++++++++++++++------------------------
> > ---
> >  1 file changed, 44 insertions(+), 41 deletions(-)
> > 
> > diff --git a/server/spicevmc.c b/server/spicevmc.c
> > index be924df..f2b3be3 100644
> > --- a/server/spicevmc.c
> > +++ b/server/spicevmc.c
> > @@ -120,7 +120,8 @@ static void
> > spicevmc_red_channel_release_msg_rcv_buf(RedChannelClient *rcc,
> >                                                       uint32_t size,
> >                                                       uint8_t *msg);
> >  
> > -static RedVmcPipeItem* try_compress_lz4(SpiceVmcState *state, int n,
> > RedVmcPipeItem *msg_item) {
> > +static RedVmcPipeItem* try_compress_lz4(SpiceVmcState *state, int n,
> > RedVmcPipeItem *msg_item)
> > +{
> >      RedVmcPipeItem *msg_item_compressed;
> >      int bound, compressed_data_count;
> >  
> > @@ -154,7 +155,9 @@ static RedVmcPipeItem* try_compress_lz4(SpiceVmcState
> > *state, int n, RedVmcPipeI
> >          msg_item_compressed->buf_used = compressed_data_count;
> >          free(msg_item);
> >          return msg_item_compressed;
> > -    }/* LZ4 compression failed-fallback a non-compressed data is to be
> > sent
> > */
> > +    }
> > +
> > +    /* LZ4 compression failed-fallback a non-compressed data is to be sent
> > */
> >      spice_warning("Compress Error");
> >      free(msg_item_compressed);
> >      return NULL;
> > @@ -193,8 +196,8 @@ static RedPipeItem
> > *spicevmc_chardev_read_msg_from_dev(SpiceCharDeviceInstance *
> >  
> >          msg_item_compressed = try_compress_lz4(state, n, msg_item);
> >          if (msg_item_compressed != NULL) {
> > -	    return (RedPipeItem *)msg_item_compressed;
> > -    }
> > +            return &msg_item_compressed->base;
> > +        }
> >  #endif
> >          msg_item->uncompressed_data_size = n;
> >          msg_item->buf_used = n;
> > @@ -340,52 +343,53 @@ static int
> > spicevmc_channel_client_handle_migrate_data(RedChannelClient *rcc,
> >      return red_char_device_restore(state->chardev, &mig_data->base);
> >  }
> >  
> > -static int try_handle_compressed_msg(RedChannelClient *rcc,
> > SpiceMsgCompressedData *compressed_data_msg) {
> > -    /*NOTE: *decompressed is free by the char-device */
> > +static int try_handle_compressed_msg(RedChannelClient *rcc,
> > SpiceMsgCompressedData *compressed_data_msg)
> > +{
> > +    /* NOTE: *decompressed is free by the char-device */
> >      SpiceVmcState *state;
> >      int decompressed_size;
> > -    char *decompressed;
> > +    uint8_t *decompressed;
> >  
> >      state = spicevmc_red_channel_client_get_state(rcc);
> > -    decompressed =
> > (char*)spicevmc_red_channel_alloc_msg_rcv_buf(rcc,SPICE_MSGC_SPICEVMC_DATA,
> > -
> >                                                                  compressed_d
> > ata_msg->uncompressed_size);
> > +    decompressed =
> > spicevmc_red_channel_alloc_msg_rcv_buf(rcc,SPICE_MSGC_SPICEVMC_DATA,
> > +
> >                                                           compressed_data_msg
> > ->uncompressed_size);
> >      switch (compressed_data_msg->type) {
> >  #ifdef USE_LZ4
> >      case SPICE_DATA_COMPRESSION_TYPE_LZ4:
> > -        decompressed_size = LZ4_decompress_safe
> > ((char*)compressed_data_msg-
> > >compressed_data,
> > -                                                 decompressed,
> > +        decompressed_size = LZ4_decompress_safe ((char
> > *)compressed_data_msg-
> > >compressed_data,
> > +                                                 (char *)decompressed,
> >                                                   compressed_data_msg-
> > >compressed_size,
> >                                                   compressed_data_msg-
> > >uncompressed_size);
> >          break;
> >  #endif
> > -        default:
> > -            spice_warning("Invalid Compression Type");
> > -
> >             spicevmc_red_channel_release_msg_rcv_buf(rcc,SPICE_MSGC_SPICEVMC_
> > DATA,
> > -                                                     compressed_data_msg-
> > >uncompressed_size,
> > -
> >                                                      (uint8_t*)decompressed);
> > -            return FALSE;
> > -        }
> > -        if (decompressed_size != compressed_data_msg->uncompressed_size) {
> > -            spice_warning("Decompression Error");
> > -            spicevmc_red_channel_release_msg_rcv_buf(rcc,
> > SPICE_MSGC_SPICEVMC_DATA,
> > -                                                     compressed_data_msg-
> > >uncompressed_size,
> > -
> >                                                      (uint8_t*)decompressed);
> > -            return FALSE;
> > -        }
> > -        spice_assert(state->recv_from_client_buf->buf ==
> > (uint8_t*)decompressed);
> > -        state->recv_from_client_buf->buf_used = decompressed_size;
> > -        red_char_device_write_buffer_add(state->chardev, state-
> > >recv_from_client_buf);
> > -        state->recv_from_client_buf = NULL;
> > -        return TRUE;
> > -
> > +    default:
> > +        spice_warning("Invalid Compression Type");
> > +
> >         spicevmc_red_channel_release_msg_rcv_buf(rcc,SPICE_MSGC_SPICEVMC_DATA
> > ,
> > +                                                 compressed_data_msg-
> > >uncompressed_size,
> > +                                                 decompressed);
> > +        return FALSE;
> > +    }
> > +    if (decompressed_size != compressed_data_msg->uncompressed_size) {
> > +        spice_warning("Decompression Error");
> > +        spicevmc_red_channel_release_msg_rcv_buf(rcc,
> > SPICE_MSGC_SPICEVMC_DATA,
> > +                                                 compressed_data_msg-
> > >uncompressed_size,
> > +                                                 decompressed);
> > +        return FALSE;
> > +    }
> > +    spice_assert(state->recv_from_client_buf->buf == decompressed);
> > +    state->recv_from_client_buf->buf_used = decompressed_size;
> > +    red_char_device_write_buffer_add(state->chardev, state-
> > >recv_from_client_buf);
> > +    state->recv_from_client_buf = NULL;
> > +    return TRUE;
> >  }
> >  
> >  static int
> >  spicevmc_red_channel_client_handle_message_parsed(RedChannelClient
> > *rcc,
> > -                                                      uint32_t size,
> > -                                                      uint16_t type,
> > -                                                      void *msg)
> > -{  /*NOTE: *msg free by free() (when cb to
> > spicevmc_red_channel_release_msg_rcv_buf
> > -    *with the compressed msg type)*/
> > +                                                             uint32_t
> > size,
> > +                                                             uint16_t
> > type,
> > +                                                             void *msg)
> > +{
> > +    /* NOTE: *msg free by free() (when cb to
> > spicevmc_red_channel_release_msg_rcv_buf
> > +     * with the compressed msg type) */
> >      SpiceVmcState *state;
> >      SpiceCharDeviceInterface *sif;
> >  
> > @@ -399,12 +403,11 @@ static int
> > spicevmc_red_channel_client_handle_message_parsed(RedChannelClient *r
> >          red_char_device_write_buffer_add(state->chardev, state-
> > >recv_from_client_buf);
> >          state->recv_from_client_buf = NULL;
> >          break;
> > -    case SPICE_MSGC_SPICEVMC_COMPRESSED_DATA: {
> > +    case SPICE_MSGC_SPICEVMC_COMPRESSED_DATA:
> >          if (!try_handle_compressed_msg(rcc, (SpiceMsgCompressedData*)msg))
> >          {
> >              return FALSE;
> > -	}
> > -	break;
> > -    }
> > +        }
> > +        break;
> >      case SPICE_MSGC_PORT_EVENT:
> >          if (size != sizeof(uint8_t)) {
> >              spice_warning("bad port event message size");
> > @@ -472,7 +475,7 @@ static void
> > spicevmc_red_channel_send_data(RedChannelClient *rcc,
> >  {
> >      RedVmcPipeItem *i = SPICE_UPCAST(RedVmcPipeItem, item);
> >  
> > -    switch (i->type){
> > +    switch (i->type) {
> >      case SPICE_DATA_COMPRESSION_TYPE_NONE:
> >          red_channel_client_init_send_data(rcc, SPICE_MSG_SPICEVMC_DATA,
> > item);
> >          spice_marshaller_add_ref(m, i->buf, i->buf_used);
> 
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]