[Spice-devel] [PATCH spice-server] Use verify instead of G_STATIC_ASSERT
Frediano Ziglio
fziglio at redhat.com
Thu Nov 30 12:00:34 UTC 2017
verify guarantee that the condition is always a compile
time constant.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/glib-compat.h | 2 +-
server/red-parse-qxl.c | 4 ++--
server/spice-bitmap-utils.h | 4 ++--
server/tests/replay.c | 22 +++++++++++-----------
server/tests/stat-test.c | 6 ++++--
5 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/server/glib-compat.h b/server/glib-compat.h
index a81bf483..d3e80a64 100644
--- a/server/glib-compat.h
+++ b/server/glib-compat.h
@@ -24,7 +24,7 @@
#if !GLIB_CHECK_VERSION(2,34,0)
#define g_clear_pointer(pp, destroy) \
G_STMT_START { \
- G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
+ verify (sizeof *(pp) == sizeof (gpointer)); \
/* Only one access, please */ \
gpointer *_pp = (gpointer *) (pp); \
gpointer _p; \
diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
index 9224b2c5..07970232 100644
--- a/server/red-parse-qxl.c
+++ b/server/red-parse-qxl.c
@@ -35,7 +35,7 @@
*/
#define MAX_DATA_CHUNK 0x7ffffffflu
-G_STATIC_ASSERT(MAX_DATA_CHUNK <= G_MAXINT32);
+verify(MAX_DATA_CHUNK <= G_MAXINT32);
/* Limit number of chunks.
* The guest can attempt to make host allocate too much memory
@@ -350,7 +350,7 @@ static SpiceClipRects *red_get_clip_rects(RedMemSlotInfo *slots, int group_id,
* by red_get_data_chunks_ptr checks.
*/
spice_assert((uint64_t) num_rects * sizeof(QXLRect) == size);
- G_STATIC_ASSERT(sizeof(SpiceRect) == sizeof(QXLRect));
+ verify(sizeof(SpiceRect) == sizeof(QXLRect));
red = g_malloc(sizeof(*red) + num_rects * sizeof(SpiceRect));
red->num_rects = num_rects;
diff --git a/server/spice-bitmap-utils.h b/server/spice-bitmap-utils.h
index 27077045..517ddabf 100644
--- a/server/spice-bitmap-utils.h
+++ b/server/spice-bitmap-utils.h
@@ -36,7 +36,7 @@ typedef struct {
uint8_t pad;
} rgb32_pixel_t;
-G_STATIC_ASSERT(sizeof(rgb32_pixel_t) == 4);
+verify(sizeof(rgb32_pixel_t) == 4);
typedef struct {
uint8_t b;
@@ -44,7 +44,7 @@ typedef struct {
uint8_t r;
} rgb24_pixel_t;
-G_STATIC_ASSERT(sizeof(rgb24_pixel_t) == 3);
+verify(sizeof(rgb24_pixel_t) == 3);
typedef uint16_t rgb16_pixel_t;
diff --git a/server/tests/replay.c b/server/tests/replay.c
index 700a2a81..d06fb657 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -356,17 +356,17 @@ int main(int argc, char **argv)
"\t1=off 2=all 3=filter";
/* these asserts are here to check that the documentation we state above is still correct */
- G_STATIC_ASSERT(SPICE_STREAM_VIDEO_OFF == 1);
- G_STATIC_ASSERT(SPICE_STREAM_VIDEO_ALL == 2);
- G_STATIC_ASSERT(SPICE_STREAM_VIDEO_FILTER == 3);
- G_STATIC_ASSERT(SPICE_IMAGE_COMPRESSION_INVALID == 0);
- G_STATIC_ASSERT(SPICE_IMAGE_COMPRESSION_OFF == 1);
- G_STATIC_ASSERT(SPICE_IMAGE_COMPRESSION_AUTO_GLZ == 2);
- G_STATIC_ASSERT(SPICE_IMAGE_COMPRESSION_AUTO_LZ == 3);
- G_STATIC_ASSERT(SPICE_IMAGE_COMPRESSION_QUIC == 4);
- G_STATIC_ASSERT(SPICE_IMAGE_COMPRESSION_GLZ == 5);
- G_STATIC_ASSERT(SPICE_IMAGE_COMPRESSION_LZ == 6);
- G_STATIC_ASSERT(SPICE_IMAGE_COMPRESSION_LZ4 == 7);
+ verify(SPICE_STREAM_VIDEO_OFF == 1);
+ verify(SPICE_STREAM_VIDEO_ALL == 2);
+ verify(SPICE_STREAM_VIDEO_FILTER == 3);
+ verify(SPICE_IMAGE_COMPRESSION_INVALID == 0);
+ verify(SPICE_IMAGE_COMPRESSION_OFF == 1);
+ verify(SPICE_IMAGE_COMPRESSION_AUTO_GLZ == 2);
+ verify(SPICE_IMAGE_COMPRESSION_AUTO_LZ == 3);
+ verify(SPICE_IMAGE_COMPRESSION_QUIC == 4);
+ verify(SPICE_IMAGE_COMPRESSION_GLZ == 5);
+ verify(SPICE_IMAGE_COMPRESSION_LZ == 6);
+ verify(SPICE_IMAGE_COMPRESSION_LZ4 == 7);
context = g_option_context_new("- replay spice server recording");
g_option_context_add_main_entries(context, entries, NULL);
diff --git a/server/tests/stat-test.c b/server/tests/stat-test.c
index 7bda79ae..7fe38a6a 100644
--- a/server/tests/stat-test.c
+++ b/server/tests/stat-test.c
@@ -34,6 +34,8 @@
#include <unistd.h>
#include <glib.h>
+#include <common/verify.h>
+
#include "../stat.h"
#ifndef TEST_NAME
@@ -49,8 +51,8 @@ void TEST_NAME(void)
stat_start_time_t start_time;
#if !defined(COMPRESS_STAT) && !defined(RED_WORKER_STAT)
- G_STATIC_ASSERT(sizeof(start_time) == 0);
- G_STATIC_ASSERT(sizeof(info) == 0);
+ verify(sizeof(start_time) == 0);
+ verify(sizeof(info) == 0);
#endif
stat_init(&info, "test", CLOCK_MONOTONIC);
--
2.14.3
More information about the Spice-devel
mailing list