[Spice-devel] [PATCH spice 05/12] Mark some variables as volatile
Daniel P. Berrange
berrange at redhat.com
Mon Apr 2 04:23:40 PDT 2012
From: "Daniel P. Berrange" <berrange at redhat.com>
When using setjmp/longjmp the state of local variables can be
undefined in certain scenarios:
[quote man(longjmp)]
The values of automatic variables are unspecified after a
call to longjmp() if they meet all the following criteria:
· they are local to the function that made the correspond‐
ing setjmp(3) call;
· their values are changed between the calls to setjmp(3)
and longjmp(); and
· they are not declared as volatile.
[/quote]
* server/red_worker.c: Mark some vars as volatile
Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
server/red_worker.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/server/red_worker.c b/server/red_worker.c
index c23bd35..45e2350 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -5917,9 +5917,9 @@ static int red_jpeg_compress_image(DisplayChannelClient *dcc, SpiceImage *dest,
LzData *lz_data = &worker->lz_data;
JpegEncoderContext *jpeg = worker->jpeg;
LzContext *lz = worker->lz;
- JpegEncoderImageType jpeg_in_type;
+ volatile JpegEncoderImageType jpeg_in_type;
int jpeg_size = 0;
- int has_alpha = FALSE;
+ volatile int has_alpha = FALSE;
int alpha_lz_size = 0;
int comp_head_filled;
int comp_head_left;
@@ -6057,7 +6057,7 @@ static inline int red_quic_compress_image(DisplayChannelClient *dcc, SpiceImage
RedWorker *worker = display_channel->common.worker;
QuicData *quic_data = &worker->quic_data;
QuicContext *quic = worker->quic;
- QuicImageType type;
+ volatile QuicImageType type;
int size, stride;
#ifdef COMPRESS_STAT
--
1.7.7.6
More information about the Spice-devel
mailing list