[Spice-devel,2/2] Fix set but not used variable warning

Submitted by Eduardo Lima (Etrunko) on June 15, 2016, 5:45 p.m.

Details

Message ID 1466012741-32747-3-git-send-email-etrunko@redhat.com
State New
Headers show
Series "Build fixes for systems without LZ4" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Eduardo Lima (Etrunko) June 15, 2016, 5:45 p.m.
Introduced by commit 903c91cd3013c763abd3f2292f8fbd911a0c83f0, this
variable is used only for LZ4 code. Move the declaration to the proper
block of code.

Build log:

spicevmc.c: In function 'handle_compressed_msg':
spicevmc.c:346:14: error: variable 'decompressed' set but not used [-Werror=unused-but-set-variable]
     uint8_t *decompressed;
                   ^

Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
 server/spicevmc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/server/spicevmc.c b/server/spicevmc.c
index e949827..ea74888 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -345,7 +345,6 @@  static int handle_compressed_msg(SpiceVmcState *state, RedChannelClient *rcc,
 {
     /* NOTE: *decompressed is free by the char-device */
     int decompressed_size;
-    uint8_t *decompressed;
     RedCharDeviceWriteBuffer *write_buf;
 
     write_buf = red_char_device_write_buffer_get(state->chardev, rcc->client,
@@ -353,11 +352,11 @@  static int handle_compressed_msg(SpiceVmcState *state, RedChannelClient *rcc,
     if (!write_buf) {
         return FALSE;
     }
-    decompressed = write_buf->buf;
 
     switch (compressed_data_msg->type) {
 #ifdef USE_LZ4
     case SPICE_DATA_COMPRESSION_TYPE_LZ4:
+        uint8_t *decompressed = write_buf->buf;
         decompressed_size = LZ4_decompress_safe ((char *)compressed_data_msg->compressed_data,
                                                  (char *)decompressed,
                                                  compressed_data_msg->compressed_size,

Comments

On 06/15/2016 02:45 PM, Eduardo Lima (Etrunko) wrote:
> Introduced by commit 903c91cd3013c763abd3f2292f8fbd911a0c83f0, this
> variable is used only for LZ4 code. Move the declaration to the proper
> block of code.
> 
> Build log:
> 
> spicevmc.c: In function 'handle_compressed_msg':
> spicevmc.c:346:14: error: variable 'decompressed' set but not used [-Werror=unused-but-set-variable]
>      uint8_t *decompressed;
>                    ^
> 
> Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
> ---
>  server/spicevmc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index e949827..ea74888 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -345,7 +345,6 @@ static int handle_compressed_msg(SpiceVmcState *state, RedChannelClient *rcc,
>  {
>      /* NOTE: *decompressed is free by the char-device */
>      int decompressed_size;
> -    uint8_t *decompressed;
>      RedCharDeviceWriteBuffer *write_buf;
>  
>      write_buf = red_char_device_write_buffer_get(state->chardev, rcc->client,
> @@ -353,11 +352,11 @@ static int handle_compressed_msg(SpiceVmcState *state, RedChannelClient *rcc,
>      if (!write_buf) {
>          return FALSE;
>      }
> -    decompressed = write_buf->buf;
>  
>      switch (compressed_data_msg->type) {
>  #ifdef USE_LZ4
>      case SPICE_DATA_COMPRESSION_TYPE_LZ4:
> +        uint8_t *decompressed = write_buf->buf;
>          decompressed_size = LZ4_decompress_safe ((char *)compressed_data_msg->compressed_data,
>                                                   (char *)decompressed,
>                                                   compressed_data_msg->compressed_size,
> 


I found that this patch is broken, due to missing curly braces. I'll
have a new version posted.