[PATCH] Remove goto within switch statement

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

 



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

_______________________________________________
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]