[Spice-commits] 3 commits - server/char-device.c server/tests
Frediano Ziglio
fziglio at kemper.freedesktop.org
Wed Jan 31 13:33:27 UTC 2018
server/char-device.c | 24 +++++++++++++-----------
server/tests/replay.c | 5 -----
server/tests/test-gst.c | 2 +-
server/tests/test-sasl.c | 2 +-
4 files changed, 15 insertions(+), 18 deletions(-)
New commits:
commit 4a0149bb1fc13fa4749096c9cac8830da26c192d
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon Jan 22 16:51:55 2018 +0000
tests: Avoid some possible not initialized warning from Clang
Not really possible but clang raise these warnings:
test-sasl.c:555:13: error: variable 'is_ok' is uninitialized when used here [-Werror,-Wuninitialized]
if (is_ok) {
^~~~~
test-sasl.c:553:22: note: initialize the variable 'is_ok' to silence this warning
uint8_t is_ok;
^
= '\0'
test-gst.c:792:18: error: variable 'height' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized]
spice_assert(gst_structure_get_int(s, "width", &width) &&
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../spice-common/common/log.h:91:17: note: expanded from macro 'spice_assert'
if G_LIKELY(x) { } else { \
^
/usr/include/glib-2.0/glib/gmacros.h:376:60: note: expanded from macro 'G_LIKELY'
^~~~
/usr/include/glib-2.0/glib/gmacros.h:370:8: note: expanded from macro '_G_BOOLEAN_EXPR'
if (expr) \
^~~~
test-gst.c:799:17: note: uninitialized use occurs here
bitmap->y = height;
^~~~~~
test-gst.c:792:18: note: remove the '&&' if its condition is always true
spice_assert(gst_structure_get_int(s, "width", &width) &&
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../spice-common/common/log.h:91:17: note: expanded from macro 'spice_assert'
if G_LIKELY(x) { } else { \
^
/usr/include/glib-2.0/glib/gmacros.h:376:60: note: expanded from macro 'G_LIKELY'
^
/usr/include/glib-2.0/glib/gmacros.h:370:8: note: expanded from macro '_G_BOOLEAN_EXPR'
if (expr) \
^
test-gst.c:791:23: note: initialize the variable 'height' to silence this warning
gint width, height;
^
= 0
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/server/tests/test-gst.c b/server/tests/test-gst.c
index ecd6c49a..91ef92d6 100644
--- a/server/tests/test-gst.c
+++ b/server/tests/test-gst.c
@@ -788,7 +788,7 @@ gst_to_spice_bitmap(GstSample *sample)
GstStructure *s = gst_caps_get_structure(caps, 0);
spice_assert(s);
- gint width, height;
+ gint width = 0, height = 0;
spice_assert(gst_structure_get_int(s, "width", &width) &&
gst_structure_get_int(s, "height", &height));
diff --git a/server/tests/test-sasl.c b/server/tests/test-sasl.c
index 25ad79af..a620ec59 100644
--- a/server/tests/test-sasl.c
+++ b/server/tests/test-sasl.c
@@ -550,7 +550,7 @@ client_emulator(int sock)
g_assert_cmpint(datalen, <=, sizeof(buf));
read_all(sock, buf, datalen);
- uint8_t is_ok;
+ uint8_t is_ok = 0;
read_all(sock, &is_ok, sizeof(is_ok));
if (is_ok) {
// is_ok should be 0 or 1
commit a5b26585a1a87c0dc0da62af80f6a3ec98e622d9
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon Jan 22 16:08:21 2018 +0000
replay: Do not use obsolete set_mm_time callback
Marked as obsolete with clang and some options is detected as
error.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/server/tests/replay.c b/server/tests/replay.c
index 0ceb7271..137f0606 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -91,10 +91,6 @@ static void set_compression_level(QXLInstance *qin, int level)
g_debug("%s\n", __func__);
}
-static void set_mm_time(QXLInstance *qin, uint32_t mm_time)
-{
-}
-
// same as qemu/ui/spice-display.h
#define MAX_SURFACE_NUM 1024
@@ -256,7 +252,6 @@ static QXLInterface display_sif = {
},
.attache_worker = attach_worker,
.set_compression_level = set_compression_level,
- .set_mm_time = set_mm_time,
.get_init_info = get_init_info,
.get_command = get_display_command,
.req_cmd_notification = req_display_notification,
commit 33f33ccc5198fd57265184f7b0128eb7f75e6ac2
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon Jan 22 16:03:53 2018 +0000
char-device: Avoid to use unaligned memory
This causes some warnings with clang:
char-device.c:898:29: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
write_to_dev_size_ptr = (uint32_t *)spice_marshaller_reserve_space(m, sizeof(uint32_t));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
char-device.c:899:31: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
write_to_dev_tokens_ptr = (uint32_t *)spice_marshaller_reserve_space(m, sizeof(uint32_t));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This also fixes some minor endianness issue (on big endian machine
integers were not properly encoded).
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
diff --git a/server/char-device.c b/server/char-device.c
index 2f8d3821..242d8782 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -880,8 +880,9 @@ void red_char_device_migrate_data_marshall(RedCharDevice *dev,
{
RedCharDeviceClient *dev_client;
GList *item;
- uint32_t *write_to_dev_size_ptr;
- uint32_t *write_to_dev_tokens_ptr;
+ uint8_t *write_to_dev_sizes_ptr;
+ uint32_t write_to_dev_size;
+ uint32_t write_to_dev_tokens;
SpiceMarshaller *m2;
/* multi-clients are not supported */
@@ -895,10 +896,9 @@ void red_char_device_migrate_data_marshall(RedCharDevice *dev,
spice_marshaller_add_uint8(m, 1); /* connected */
spice_marshaller_add_uint32(m, dev_client->num_client_tokens);
spice_marshaller_add_uint32(m, dev_client->num_send_tokens);
- write_to_dev_size_ptr = (uint32_t *)spice_marshaller_reserve_space(m, sizeof(uint32_t));
- write_to_dev_tokens_ptr = (uint32_t *)spice_marshaller_reserve_space(m, sizeof(uint32_t));
- *write_to_dev_size_ptr = 0;
- *write_to_dev_tokens_ptr = 0;
+ write_to_dev_sizes_ptr = spice_marshaller_reserve_space(m, sizeof(uint32_t)*2);
+ write_to_dev_size = 0;
+ write_to_dev_tokens = 0;
m2 = spice_marshaller_get_ptr_submarshaller(m, 0);
if (dev->priv->cur_write_buf) {
@@ -908,10 +908,10 @@ void red_char_device_migrate_data_marshall(RedCharDevice *dev,
migrate_data_marshaller_write_buffer_free,
red_char_device_write_buffer_ref(dev->priv->cur_write_buf)
);
- *write_to_dev_size_ptr += buf_remaining;
+ write_to_dev_size += buf_remaining;
if (dev->priv->cur_write_buf->priv->origin == WRITE_BUFFER_ORIGIN_CLIENT) {
spice_assert(dev->priv->cur_write_buf->priv->client == dev_client->client);
- (*write_to_dev_tokens_ptr) += dev->priv->cur_write_buf->priv->token_price;
+ write_to_dev_tokens += dev->priv->cur_write_buf->priv->token_price;
}
}
@@ -922,14 +922,16 @@ void red_char_device_migrate_data_marshall(RedCharDevice *dev,
migrate_data_marshaller_write_buffer_free,
red_char_device_write_buffer_ref(write_buf)
);
- *write_to_dev_size_ptr += write_buf->buf_used;
+ write_to_dev_size += write_buf->buf_used;
if (write_buf->priv->origin == WRITE_BUFFER_ORIGIN_CLIENT) {
spice_assert(write_buf->priv->client == dev_client->client);
- (*write_to_dev_tokens_ptr) += write_buf->priv->token_price;
+ write_to_dev_tokens += write_buf->priv->token_price;
}
}
spice_debug("migration data dev %p: write_queue size %u tokens %u",
- dev, *write_to_dev_size_ptr, *write_to_dev_tokens_ptr);
+ dev, write_to_dev_size, write_to_dev_tokens);
+ spice_marshaller_set_uint32(m, write_to_dev_sizes_ptr, write_to_dev_size);
+ spice_marshaller_set_uint32(m, write_to_dev_sizes_ptr + sizeof(uint32_t), write_to_dev_tokens);
}
bool red_char_device_restore(RedCharDevice *dev,
More information about the Spice-commits
mailing list