[Spice-devel] [PATCH] Remove goto within switch statement
Jonathon Jongsma
jjongsma at redhat.com
Tue Jun 14 21:04:27 UTC 2016
Having a goto label in the middle of a switch/case statement is a bit
confusing. But the same behavior can be achieved 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);
}
--
2.5.5
More information about the Spice-devel
mailing list