From eb6b20a502f7c20b6a5cfc9155dcbf2cb06c895e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 20 Oct 2016 20:51:04 -0700 Subject: A few volatile fixes related to setjmp. * socket.c (dgram_get_byte_callback): nbytes must be volatile because we assign to it after setting up the catch, and then access it in the unwind code. (sock_accept): Likewise. * stream.c (generic_get_line): buf variable must be volatile. (struct save_fds): The members of this structure must be volatile; it's used as a local variable in a number of functions in a way that requires volatile. --- socket.c | 4 ++-- stream.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/socket.c b/socket.c index fe0c4a83..564db0ef 100644 --- a/socket.c +++ b/socket.c @@ -408,7 +408,7 @@ static int dgram_get_byte_callback(mem_t *ctx) } else { const int dgram_size = d->rx_max; mem_t *dgram = chk_malloc(dgram_size); - ssize_t nbytes = -1; + volatile ssize_t nbytes = -1; uw_simple_catch_begin; @@ -895,7 +895,7 @@ static val sock_accept(val sock, val mode_str, val timeout_in) if (type == num_fast(SOCK_DGRAM)) { struct dgram_stream *d = coerce(struct dgram_stream *, sock->co.handle); - ssize_t nbytes = -1; + volatile ssize_t nbytes = -1; const int dgram_size = d->rx_max; mem_t *dgram = chk_malloc(dgram_size); diff --git a/stream.c b/stream.c index 3282b7f6..55b501c1 100644 --- a/stream.c +++ b/stream.c @@ -691,7 +691,7 @@ val generic_get_line(val stream) const size_t min_size = 512; size_t size = 0; size_t fill = 0; - wchar_t *buf = 0; + wchar_t *volatile buf = 0; val out = nil; uw_simple_catch_begin; @@ -3650,9 +3650,9 @@ val open_tail(val path, val mode_str, val seek_end_p) } struct save_fds { - int in; - int out; - int err; + volatile int in; + volatile int out; + volatile int err; }; #define FDS_IN 1 -- cgit v1.2.3