summaryrefslogtreecommitdiffstats
path: root/server/reds.c
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2012-03-13 16:11:03 +0000
committerDaniel P. Berrange <berrange@redhat.com>2012-04-25 09:42:15 +0100
commit84c7a95c22ba3a0fc5623c7cd66c9793e02ebcf8 (patch)
tree95729c06689a8ddcb161c6884486112d45eb01a6 /server/reds.c
parent3be7df09800f8a823ec307830fd8d3f26f28ffc6 (diff)
downloadspice-84c7a95c22ba3a0fc5623c7cd66c9793e02ebcf8.tar.gz
spice-84c7a95c22ba3a0fc5623c7cd66c9793e02ebcf8.tar.xz
spice-84c7a95c22ba3a0fc5623c7cd66c9793e02ebcf8.zip
Avoid jumping across variables declarations with initializers
If a 'goto' statement jumps across a variable declaration which also has an initializer, the variable is in an undefined state. Splitting the the declaration & initialization doesn't change that, but the compiler can at least now detect use of the unintialized variable Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'server/reds.c')
-rw-r--r--server/reds.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/server/reds.c b/server/reds.c
index 8ae569ca..1696fbc7 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3666,9 +3666,10 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
reds->vdi_port_write_timer_started = FALSE;
#ifdef RED_STATISTICS
- int shm_name_len = strlen(SPICE_STAT_SHM_NAME) + 20;
+ int shm_name_len;
int fd;
+ shm_name_len = strlen(SPICE_STAT_SHM_NAME) + 20;
reds->stat_shm_name = (char *)spice_malloc(shm_name_len);
snprintf(reds->stat_shm_name, shm_name_len, SPICE_STAT_SHM_NAME, getpid());
if ((fd = shm_open(reds->stat_shm_name, O_CREAT | O_RDWR, 0444)) == -1) {