Seems I got behind on email and ACKed the previous version already. Oops. Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx> On Thu, 2017-11-30 at 16:42 +0000, Frediano Ziglio wrote: > verify guarantee that the condition is always a compile > time constant. > > Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> > --- > 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(-) > > Changes since v1: > - compatibility with RHEL6, we need to use SPICE_VERIFY inside > functions. > > diff --git a/server/glib-compat.h b/server/glib-compat.h > index a81bf483..2444ac3b 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)); \ > + SPICE_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..b4325b04 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)); > + SPICE_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..e459ca26 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); > + SPICE_VERIFY(SPICE_STREAM_VIDEO_OFF == 1); > + SPICE_VERIFY(SPICE_STREAM_VIDEO_ALL == 2); > + SPICE_VERIFY(SPICE_STREAM_VIDEO_FILTER == 3); > + SPICE_VERIFY(SPICE_IMAGE_COMPRESSION_INVALID == 0); > + SPICE_VERIFY(SPICE_IMAGE_COMPRESSION_OFF == 1); > + SPICE_VERIFY(SPICE_IMAGE_COMPRESSION_AUTO_GLZ == 2); > + SPICE_VERIFY(SPICE_IMAGE_COMPRESSION_AUTO_LZ == 3); > + SPICE_VERIFY(SPICE_IMAGE_COMPRESSION_QUIC == 4); > + SPICE_VERIFY(SPICE_IMAGE_COMPRESSION_GLZ == 5); > + SPICE_VERIFY(SPICE_IMAGE_COMPRESSION_LZ == 6); > + SPICE_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..e4a83f4f 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/macros.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); > + SPICE_VERIFY(sizeof(start_time) == 0); > + SPICE_VERIFY(sizeof(info) == 0); > #endif > > stat_init(&info, "test", CLOCK_MONOTONIC); _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel