[Spice-devel] [PATCH spice-server v2 10/12] Check image compression value earlier
Frediano Ziglio
fziglio at redhat.com
Tue Mar 26 19:10:36 UTC 2019
Do not check it after assigning to reds->config->image_compression,
check the value as soon as possible.
This prevent potential invalid settings.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/red-worker.c | 28 ----------------------------
server/reds.c | 34 +++++++++++++++++++++++++++++++---
2 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/server/red-worker.c b/server/red-worker.c
index d883f419..7382e24d 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -684,34 +684,6 @@ static void handle_dev_set_compression(void *opaque, void *payload)
RedWorker *worker = opaque;
SpiceImageCompression image_compression = msg->image_compression;
- switch (image_compression) {
- case SPICE_IMAGE_COMPRESSION_AUTO_LZ:
- spice_debug("ic auto_lz");
- break;
- case SPICE_IMAGE_COMPRESSION_AUTO_GLZ:
- spice_debug("ic auto_glz");
- break;
- case SPICE_IMAGE_COMPRESSION_QUIC:
- spice_debug("ic quic");
- break;
-#ifdef USE_LZ4
- case SPICE_IMAGE_COMPRESSION_LZ4:
- spice_debug("ic lz4");
- break;
-#endif
- case SPICE_IMAGE_COMPRESSION_LZ:
- spice_debug("ic lz");
- break;
- case SPICE_IMAGE_COMPRESSION_GLZ:
- spice_debug("ic glz");
- break;
- case SPICE_IMAGE_COMPRESSION_OFF:
- spice_debug("ic off");
- break;
- default:
- spice_warning("ic invalid");
- image_compression = worker->image_compression;
- }
worker->image_compression = image_compression;
display_channel_compress_stats_print(worker->display_channel);
diff --git a/server/reds.c b/server/reds.c
index 14e5728b..28542bd0 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3010,12 +3010,40 @@ static inline void on_activating_ticketing(RedsState *reds)
}
}
-static void reds_config_set_image_compression(RedsState *reds, SpiceImageCompression val)
+static void reds_config_set_image_compression(RedsState *reds, SpiceImageCompression image_compression)
{
- if (val == reds->config->image_compression) {
+ if (image_compression == reds->config->image_compression) {
return;
}
- reds->config->image_compression = val;
+ switch (image_compression) {
+ case SPICE_IMAGE_COMPRESSION_AUTO_LZ:
+ spice_debug("ic auto_lz");
+ break;
+ case SPICE_IMAGE_COMPRESSION_AUTO_GLZ:
+ spice_debug("ic auto_glz");
+ break;
+ case SPICE_IMAGE_COMPRESSION_QUIC:
+ spice_debug("ic quic");
+ break;
+#ifdef USE_LZ4
+ case SPICE_IMAGE_COMPRESSION_LZ4:
+ spice_debug("ic lz4");
+ break;
+#endif
+ case SPICE_IMAGE_COMPRESSION_LZ:
+ spice_debug("ic lz");
+ break;
+ case SPICE_IMAGE_COMPRESSION_GLZ:
+ spice_debug("ic glz");
+ break;
+ case SPICE_IMAGE_COMPRESSION_OFF:
+ spice_debug("ic off");
+ break;
+ default:
+ spice_warning("ic invalid");
+ return;
+ }
+ reds->config->image_compression = image_compression;
reds_on_ic_change(reds);
}
--
2.20.1
More information about the Spice-devel
mailing list