Rather than using #ifdef COMPRESS_DEBUG spice_info(...); #endif we can #define COMPRESS_DEBUG to spice_debug() or to do nothing for a slight readability improvement. This opportunity is used to replace these spice_info() calls with g_debug(). The "do nothing" macro is a bit convoluted to ensure that we will have a compile-time check for our g_debug args. Signed-off-by: Christophe Fergeau <cfergeau@xxxxxxxxxx> --- Changes since v1: - adjust/fix commit log - use slighly more sophisticated COMPRESS_DEBUG macros for improved static checks server/image-encoders.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/server/image-encoders.c b/server/image-encoders.c index 880972e70..88073a3ee 100644 --- a/server/image-encoders.c +++ b/server/image-encoders.c @@ -32,6 +32,14 @@ #define MAX_GLZ_DRAWABLE_INSTANCES 2 +#if 0 +#define COMPRESS_DEBUG(...) g_debug(__VA_ARGS__) +#else +#define COMPRESS_DEBUG(...) G_STMT_START { \ + if (0) g_debug(__VA_ARGS__); \ + } G_STMT_END +#endif + typedef struct RedGlzDrawable RedGlzDrawable; typedef struct GlzDrawableInstanceItem GlzDrawableInstanceItem; @@ -837,9 +845,7 @@ bool image_encoders_compress_quic(ImageEncoders *enc, SpiceImage *dest, stat_start_time_t start_time; stat_start_time_init(&start_time, &enc->shared_data->quic_stat); -#ifdef COMPRESS_DEBUG - spice_debug("QUIC compress"); -#endif + COMPRESS_DEBUG("QUIC compress"); switch (src->format) { case SPICE_BITMAP_FMT_32BIT: @@ -926,9 +932,7 @@ bool image_encoders_compress_lz(ImageEncoders *enc, stat_start_time_t start_time; stat_start_time_init(&start_time, &enc->shared_data->lz_stat); -#ifdef COMPRESS_DEBUG - spice_debug("LZ LOCAL compress"); -#endif + COMPRESS_DEBUG("LZ LOCAL compress"); encoder_data_init(&lz_data->data); @@ -997,9 +1001,7 @@ bool image_encoders_compress_jpeg(ImageEncoders *enc, SpiceImage *dest, stat_start_time_t start_time; stat_start_time_init(&start_time, &enc->shared_data->jpeg_alpha_stat); -#ifdef COMPRESS_DEBUG - spice_debug("JPEG compress"); -#endif + COMPRESS_DEBUG("JPEG compress"); switch (src->format) { case SPICE_BITMAP_FMT_16BIT: @@ -1114,9 +1116,7 @@ bool image_encoders_compress_lz4(ImageEncoders *enc, SpiceImage *dest, stat_start_time_t start_time; stat_start_time_init(&start_time, &enc->shared_data->lz4_stat); -#ifdef COMPRESS_DEBUG - spice_debug("LZ4 compress"); -#endif + COMPRESS_DEBUG("LZ4 compress"); encoder_data_init(&lz4_data->data); @@ -1226,9 +1226,7 @@ bool image_encoders_compress_glz(ImageEncoders *enc, int glz_size; int zlib_size; -#ifdef COMPRESS_DEBUG - spice_debug("LZ global compress fmt=%d", src->format); -#endif + COMPRESS_DEBUG("LZ global compress fmt=%d", src->format); if ((src->x * src->y) >= glz_enc_dictionary_get_size(enc->glz_dict->dict)) { return FALSE; -- 2.17.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel