[Spice-devel] [PATCH] Remove goto within switch statement
Pavel Grunt
pgrunt at redhat.com
Wed Jun 15 06:18:17 UTC 2016
Hi Jonathon,
On Tue, 2016-06-14 at 16:04 -0500, Jonathon Jongsma wrote:
> Having a goto label in the middle of a switch/case statement is a bit
> confusing. But the same behavior can be achieved
it changes the behavior - if LZ4 compression is selected on server but it is not
supported on the client, then LZ compression should be used.
With your patch it skips compression and fallback to spice_error() call.
Pavel
> by simply rearranging
> the cases so that we fall through to the one that we wanted to jump to.
> ---
>
> This should apply on top of frediano's encapsulation patch series.
>
> server/dcc.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/server/dcc.c b/server/dcc.c
> index ca5569e..cf4fc77 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -747,7 +747,13 @@ int dcc_compress_image(DisplayChannelClient *dcc,
> if (success) {
> break;
> }
> - goto lz_compress;
> + /* on failure, fall through to compress with LZ */
> + case SPICE_IMAGE_COMPRESSION_LZ:
> + success = image_encoders_compress_lz(&dcc->encoders, dest, src,
> o_comp_data);
> + if (success && !bitmap_fmt_is_rgb(src->format)) {
> + dcc_palette_cache_palette(dcc, dest->u.lz_plt.palette, &(dest-
> >u.lz_plt.flags));
> + }
> + break;
> #ifdef USE_LZ4
> case SPICE_IMAGE_COMPRESSION_LZ4:
> if (red_channel_client_test_remote_cap(&dcc->common.base,
> @@ -756,13 +762,6 @@ int dcc_compress_image(DisplayChannelClient *dcc,
> break;
> }
> #endif
> -lz_compress:
> - case SPICE_IMAGE_COMPRESSION_LZ:
> - success = image_encoders_compress_lz(&dcc->encoders, dest, src,
> o_comp_data);
> - if (success && !bitmap_fmt_is_rgb(src->format)) {
> - dcc_palette_cache_palette(dcc, dest->u.lz_plt.palette, &(dest-
> >u.lz_plt.flags));
> - }
> - break;
> default:
> spice_error("invalid image compression type %u", image_compression);
> }
More information about the Spice-devel
mailing list