This buffer was just written and then used, no reason to store into
a more persistent structure.

Signed-off-by: Frediano Ziglio <fzig...@redhat.com>
---
 server/dcc-encoders.c | 34 ++++++++++++++++++----------------
 server/dcc-encoders.h |  1 -
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/server/dcc-encoders.c b/server/dcc-encoders.c
index beacb30..e18dadb 100644
--- a/server/dcc-encoders.c
+++ b/server/dcc-encoders.c
@@ -84,11 +84,12 @@ quic_usr_error(QuicUsrContext *usr, const char *fmt, ...)
 {
     EncoderData *usr_data = &(((QuicData *)usr)->data);
     va_list ap;
+    char message_buf[512];
 
     va_start(ap, fmt);
-    vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
+    vsnprintf(message_buf, sizeof(message_buf), fmt, ap);
     va_end(ap);
-    spice_critical("%s", usr_data->message_buf);
+    spice_critical("%s", message_buf);
 
     longjmp(usr_data->jmp_env, 1);
 }
@@ -98,11 +99,12 @@ lz_usr_error(LzUsrContext *usr, const char *fmt, ...)
 {
     EncoderData *usr_data = &(((LzData *)usr)->data);
     va_list ap;
+    char message_buf[512];
 
     va_start(ap, fmt);
-    vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
+    vsnprintf(message_buf, sizeof(message_buf), fmt, ap);
     va_end(ap);
-    spice_critical("%s", usr_data->message_buf);
+    spice_critical("%s", message_buf);
 
     longjmp(usr_data->jmp_env, 1);
 }
@@ -110,14 +112,14 @@ lz_usr_error(LzUsrContext *usr, const char *fmt, ...)
 static SPICE_GNUC_PRINTF(2, 3) void
 glz_usr_error(GlzEncoderUsrContext *usr, const char *fmt, ...)
 {
-    EncoderData *usr_data = &(((GlzData *)usr)->data);
     va_list ap;
+    char message_buf[512];
 
     va_start(ap, fmt);
-    vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
+    vsnprintf(message_buf, sizeof(message_buf), fmt, ap);
     va_end(ap);
 
-    spice_critical("%s", usr_data->message_buf); // if global lz fails in the 
middle
+    spice_critical("%s", message_buf); // if global lz fails in the middle
                                         // the consequences are not 
predictable since the window
                                         // can turn to be unsynchronized 
between the server and
                                         // and the client
@@ -126,37 +128,37 @@ glz_usr_error(GlzEncoderUsrContext *usr, const char *fmt, 
...)
 static SPICE_GNUC_PRINTF(2, 3) void
 quic_usr_warn(QuicUsrContext *usr, const char *fmt, ...)
 {
-    EncoderData *usr_data = &(((QuicData *)usr)->data);
     va_list ap;
+    char message_buf[512];
 
     va_start(ap, fmt);
-    vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
+    vsnprintf(message_buf, sizeof(message_buf), fmt, ap);
     va_end(ap);
-    spice_warning("%s", usr_data->message_buf);
+    spice_warning("%s", message_buf);
 }
 
 static SPICE_GNUC_PRINTF(2, 3) void
 lz_usr_warn(LzUsrContext *usr, const char *fmt, ...)
 {
-    EncoderData *usr_data = &(((LzData *)usr)->data);
     va_list ap;
+    char message_buf[512];
 
     va_start(ap, fmt);
-    vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
+    vsnprintf(message_buf, sizeof(message_buf), fmt, ap);
     va_end(ap);
-    spice_warning("%s", usr_data->message_buf);
+    spice_warning("%s", message_buf);
 }
 
 static SPICE_GNUC_PRINTF(2, 3) void
 glz_usr_warn(GlzEncoderUsrContext *usr, const char *fmt, ...)
 {
-    EncoderData *usr_data = &(((GlzData *)usr)->data);
     va_list ap;
+    char message_buf[512];
 
     va_start(ap, fmt);
-    vsnprintf(usr_data->message_buf, sizeof(usr_data->message_buf), fmt, ap);
+    vsnprintf(message_buf, sizeof(message_buf), fmt, ap);
     va_end(ap);
-    spice_warning("%s", usr_data->message_buf);
+    spice_warning("%s", message_buf);
 }
 
 static void *quic_usr_malloc(QuicUsrContext *usr, int size)
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h
index 75962ad..0e072b5 100644
--- a/server/dcc-encoders.h
+++ b/server/dcc-encoders.h
@@ -98,7 +98,6 @@ typedef struct  {
             int size_left;
         } compressed_data; // for encoding data that was already compressed by 
another method
     } u;
-    char message_buf[512];
 } EncoderData;
 
 typedef struct {
-- 
2.7.4

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to