[Spice-devel] [spice-common 02/14] quic: Use upper-case for constant names

Christophe Fergeau cfergeau at redhat.com
Wed Jul 5 08:20:36 UTC 2017


Constants, especially when defined using #define usually use upper-case
naming.
---
 common/quic.c          | 24 ++++++++++++------------
 common/quic_rgb_tmpl.c | 40 ++++++++++++++++++++--------------------
 common/quic_tmpl.c     | 40 ++++++++++++++++++++--------------------
 3 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/common/quic.c b/common/quic.c
index b7d8347..5fc0c0c 100644
--- a/common/quic.c
+++ b/common/quic.c
@@ -173,13 +173,13 @@ struct Encoder {
 };
 
 /* target wait mask index */
-static const int wmimax = DEFwmimax;
+static const int WMIMAX = DEFwmimax;
 
 /* number of symbols to encode before increasing wait mask index */
-static const int wminext = DEFwminext;
+static const int WMINEXT = DEFwminext;
 
 /* model evolution mode */
-#define evol DEFevol
+#define EVOL DEFevol
 
 /* bppmask[i] contains i ones as lsb-s */
 static const unsigned long int bppmask[33] = {
@@ -248,14 +248,14 @@ static unsigned int tabrand(unsigned int *tabrand_seed)
     return tabrand_chaos[++*tabrand_seed & TABRAND_SEEDMASK];
 }
 
-static const unsigned short besttrigtab[3][11] = { /* array of wm_trigger for waitmask and evol,
+static const unsigned short besttrigtab[3][11] = { /* array of wm_trigger for waitmask and EVOL,
                                                     used by set_wm_trigger() */
     /* 1 */ { 550, 900, 800, 700, 500, 350, 300, 200, 180, 180, 160},
     /* 3 */ { 110, 550, 900, 800, 550, 400, 350, 250, 140, 160, 140},
     /* 5 */ { 100, 120, 550, 900, 700, 500, 400, 300, 220, 250, 160}
 };
 
-/* set wm_trigger knowing waitmask (param) and evol (glob)*/
+/* set wm_trigger knowing waitmask (param) and EVOL (glob)*/
 static void set_wm_trigger(CommonState *state)
 {
     unsigned int wm = state->wmidx;
@@ -263,9 +263,9 @@ static void set_wm_trigger(CommonState *state)
         wm = 10;
     }
 
-    spice_assert(evol < 6);
+    spice_assert(EVOL < 6);
 
-    state->wm_trigger = besttrigtab[evol / 2][wm];
+    state->wm_trigger = besttrigtab[EVOL / 2][wm];
 
     spice_assert(state->wm_trigger <= 2000);
     spice_assert(state->wm_trigger >= 1);
@@ -878,7 +878,7 @@ static void find_model_params(Encoder *encoder,
     /* The only valid values are 1, 3 and 5.
        0, 2 and 4 are obsolete and the rest of the
        values are considered out of the range. */
-    SPICE_VERIFY(evol == 1 || evol == 3 || evol == 5);
+    SPICE_VERIFY(EVOL == 1 || EVOL == 3 || EVOL == 5);
     spice_assert(bpc <= 8 && bpc > 0);
 
     *ncounters = 8;
@@ -887,7 +887,7 @@ static void find_model_params(Encoder *encoder,
 
     *n_buckets_ptrs = 0;  /* ==0 means: not set yet */
 
-    switch (evol) {   /* set repfirst firstsize repnext mulsize */
+    switch (EVOL) {   /* set repfirst firstsize repnext mulsize */
     case 1: /* buckets contain following numbers of contexts: 1 1 1 2 2 4 4 8 8 ... */
         *repfirst = 3;
         *firstsize = 1;
@@ -907,7 +907,7 @@ static void find_model_params(Encoder *encoder,
         *mulsize = 4;
         break;
     default:
-        encoder->usr->error(encoder->usr, "findmodelparams(): evol out of range!!!\n");
+        encoder->usr->error(encoder->usr, "findmodelparams(): EVOL out of range!!!\n");
         return;
     }
 
@@ -1069,7 +1069,7 @@ static int encoder_reset(Encoder *encoder, uint32_t *io_ptr, uint32_t *io_ptr_en
     encoder->rgb_state.waitcnt = 0;
     encoder->rgb_state.tabrand_seed = stabrand();
     encoder->rgb_state.wmidx = DEFwmistart;
-    encoder->rgb_state.wmileft = wminext;
+    encoder->rgb_state.wmileft = WMINEXT;
     set_wm_trigger(&encoder->rgb_state);
 
 #if defined(RLE) && defined(RLE_STAT)
@@ -1133,7 +1133,7 @@ static int encoder_reset_channels(Encoder *encoder, int channels, int width, int
         encoder->channels[i].state.waitcnt = 0;
         encoder->channels[i].state.tabrand_seed = stabrand();
         encoder->channels[i].state.wmidx = DEFwmistart;
-        encoder->channels[i].state.wmileft = wminext;
+        encoder->channels[i].state.wmileft = WMINEXT;
         set_wm_trigger(&encoder->channels[i].state);
 
 #if defined(RLE) && defined(RLE_STAT)
diff --git a/common/quic_rgb_tmpl.c b/common/quic_rgb_tmpl.c
index f807a0c..451e1fd 100644
--- a/common/quic_rgb_tmpl.c
+++ b/common/quic_rgb_tmpl.c
@@ -284,7 +284,7 @@ static void FNAME(compress_row0)(Encoder *encoder, const PIXEL *cur_row,
     const unsigned int bpc_mask = BPC_MASK;
     int pos = 0;
 
-    while ((wmimax > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
+    while ((WMIMAX > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
         if (encoder->rgb_state.wmileft) {
             FNAME(compress_row0_seg)(encoder, pos, cur_row, pos + encoder->rgb_state.wmileft,
                                      bppmask[encoder->rgb_state.wmidx], bpc, bpc_mask);
@@ -294,20 +294,20 @@ static void FNAME(compress_row0)(Encoder *encoder, const PIXEL *cur_row,
 
         encoder->rgb_state.wmidx++;
         set_wm_trigger(&encoder->rgb_state);
-        encoder->rgb_state.wmileft = wminext;
+        encoder->rgb_state.wmileft = WMINEXT;
     }
 
     if (width) {
         FNAME(compress_row0_seg)(encoder, pos, cur_row, pos + width,
                                  bppmask[encoder->rgb_state.wmidx], bpc, bpc_mask);
-        if (wmimax > (int)encoder->rgb_state.wmidx) {
+        if (WMIMAX > (int)encoder->rgb_state.wmidx) {
             encoder->rgb_state.wmileft -= width;
         }
     }
 
-    spice_assert((int)encoder->rgb_state.wmidx <= wmimax);
+    spice_assert((int)encoder->rgb_state.wmidx <= WMIMAX);
     spice_assert(encoder->rgb_state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(WMINEXT > 0);
 }
 
 #define COMPRESS_ONE_0(channel) \
@@ -428,7 +428,7 @@ static void FNAME(compress_row)(Encoder *encoder,
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
 
-    while ((wmimax > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
+    while ((WMIMAX > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
         if (encoder->rgb_state.wmileft) {
             FNAME(compress_row_seg)(encoder, pos, prev_row, cur_row,
                                     pos + encoder->rgb_state.wmileft,
@@ -440,20 +440,20 @@ static void FNAME(compress_row)(Encoder *encoder,
 
         encoder->rgb_state.wmidx++;
         set_wm_trigger(&encoder->rgb_state);
-        encoder->rgb_state.wmileft = wminext;
+        encoder->rgb_state.wmileft = WMINEXT;
     }
 
     if (width) {
         FNAME(compress_row_seg)(encoder, pos, prev_row, cur_row, pos + width,
                                 bppmask[encoder->rgb_state.wmidx], bpc, bpc_mask);
-        if (wmimax > (int)encoder->rgb_state.wmidx) {
+        if (WMIMAX > (int)encoder->rgb_state.wmidx) {
             encoder->rgb_state.wmileft -= width;
         }
     }
 
-    spice_assert((int)encoder->rgb_state.wmidx <= wmimax);
+    spice_assert((int)encoder->rgb_state.wmidx <= WMIMAX);
     spice_assert(encoder->rgb_state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(WMINEXT > 0);
 }
 
 #endif
@@ -544,7 +544,7 @@ static void FNAME(uncompress_row0)(Encoder *encoder,
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
 
-    while ((wmimax > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
+    while ((WMIMAX > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
         if (encoder->rgb_state.wmileft) {
             FNAME(uncompress_row0_seg)(encoder, pos, cur_row,
                                        pos + encoder->rgb_state.wmileft,
@@ -556,20 +556,20 @@ static void FNAME(uncompress_row0)(Encoder *encoder,
 
         encoder->rgb_state.wmidx++;
         set_wm_trigger(&encoder->rgb_state);
-        encoder->rgb_state.wmileft = wminext;
+        encoder->rgb_state.wmileft = WMINEXT;
     }
 
     if (width) {
         FNAME(uncompress_row0_seg)(encoder, pos, cur_row, pos + width,
                                    bppmask[encoder->rgb_state.wmidx], bpc, bpc_mask);
-        if (wmimax > (int)encoder->rgb_state.wmidx) {
+        if (WMIMAX > (int)encoder->rgb_state.wmidx) {
             encoder->rgb_state.wmileft -= width;
         }
     }
 
-    spice_assert((int)encoder->rgb_state.wmidx <= wmimax);
+    spice_assert((int)encoder->rgb_state.wmidx <= WMIMAX);
     spice_assert(encoder->rgb_state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(WMINEXT > 0);
 }
 
 #define UNCOMPRESS_ONE_0(channel) \
@@ -700,7 +700,7 @@ static void FNAME(uncompress_row)(Encoder *encoder,
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
 
-    while ((wmimax > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
+    while ((WMIMAX > (int)encoder->rgb_state.wmidx) && (encoder->rgb_state.wmileft <= width)) {
         if (encoder->rgb_state.wmileft) {
             FNAME(uncompress_row_seg)(encoder, prev_row, cur_row, pos,
                                       pos + encoder->rgb_state.wmileft, bpc, bpc_mask);
@@ -710,20 +710,20 @@ static void FNAME(uncompress_row)(Encoder *encoder,
 
         encoder->rgb_state.wmidx++;
         set_wm_trigger(&encoder->rgb_state);
-        encoder->rgb_state.wmileft = wminext;
+        encoder->rgb_state.wmileft = WMINEXT;
     }
 
     if (width) {
         FNAME(uncompress_row_seg)(encoder, prev_row, cur_row, pos,
                                   pos + width, bpc, bpc_mask);
-        if (wmimax > (int)encoder->rgb_state.wmidx) {
+        if (WMIMAX > (int)encoder->rgb_state.wmidx) {
             encoder->rgb_state.wmileft -= width;
         }
     }
 
-    spice_assert((int)encoder->rgb_state.wmidx <= wmimax);
+    spice_assert((int)encoder->rgb_state.wmidx <= WMIMAX);
     spice_assert(encoder->rgb_state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(WMINEXT > 0);
 }
 
 #undef PIXEL
diff --git a/common/quic_tmpl.c b/common/quic_tmpl.c
index e839346..048fb3d 100644
--- a/common/quic_tmpl.c
+++ b/common/quic_tmpl.c
@@ -212,7 +212,7 @@ static void FNAME(compress_row0)(Encoder *encoder, Channel *channel, const PIXEL
     const unsigned int bpc_mask = BPC_MASK;
     int pos = 0;
 
-    while ((wmimax > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
+    while ((WMIMAX > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
         if (channel->state.wmileft) {
             FNAME(compress_row0_seg)(encoder, channel, pos, cur_row, pos + channel->state.wmileft,
                                      bppmask[channel->state.wmidx], bpc, bpc_mask);
@@ -222,20 +222,20 @@ static void FNAME(compress_row0)(Encoder *encoder, Channel *channel, const PIXEL
 
         channel->state.wmidx++;
         set_wm_trigger(&channel->state);
-        channel->state.wmileft = wminext;
+        channel->state.wmileft = WMINEXT;
     }
 
     if (width) {
         FNAME(compress_row0_seg)(encoder, channel, pos, cur_row, pos + width,
                                  bppmask[channel->state.wmidx], bpc, bpc_mask);
-        if (wmimax > (int)channel->state.wmidx) {
+        if (WMIMAX > (int)channel->state.wmidx) {
             channel->state.wmileft -= width;
         }
     }
 
-    spice_assert((int)channel->state.wmidx <= wmimax);
+    spice_assert((int)channel->state.wmidx <= WMIMAX);
     spice_assert(channel->state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(WMINEXT > 0);
 }
 
 static void FNAME(compress_row_seg)(Encoder *encoder, Channel *channel, int i,
@@ -353,7 +353,7 @@ static void FNAME(compress_row)(Encoder *encoder, Channel *channel,
     const unsigned int bpc_mask = BPC_MASK;
     unsigned int pos = 0;
 
-    while ((wmimax > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
+    while ((WMIMAX > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
         if (channel->state.wmileft) {
             FNAME(compress_row_seg)(encoder, channel, pos, prev_row, cur_row,
                                     pos + channel->state.wmileft, bppmask[channel->state.wmidx],
@@ -364,20 +364,20 @@ static void FNAME(compress_row)(Encoder *encoder, Channel *channel,
 
         channel->state.wmidx++;
         set_wm_trigger(&channel->state);
-        channel->state.wmileft = wminext;
+        channel->state.wmileft = WMINEXT;
     }
 
     if (width) {
         FNAME(compress_row_seg)(encoder, channel, pos, prev_row, cur_row, pos + width,
                                 bppmask[channel->state.wmidx], bpc, bpc_mask);
-        if (wmimax > (int)channel->state.wmidx) {
+        if (WMIMAX > (int)channel->state.wmidx) {
             channel->state.wmileft -= width;
         }
     }
 
-    spice_assert((int)channel->state.wmidx <= wmimax);
+    spice_assert((int)channel->state.wmidx <= WMIMAX);
     spice_assert(channel->state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(WMINEXT > 0);
 }
 
 static void FNAME(uncompress_row0_seg)(Encoder *encoder, Channel *channel, int i,
@@ -453,7 +453,7 @@ static void FNAME(uncompress_row0)(Encoder *encoder, Channel *channel,
     BYTE * const correlate_row = channel->correlate_row;
     unsigned int pos = 0;
 
-    while ((wmimax > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
+    while ((WMIMAX > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
         if (channel->state.wmileft) {
             FNAME(uncompress_row0_seg)(encoder, channel, pos, correlate_row, cur_row,
                                        pos + channel->state.wmileft, bppmask[channel->state.wmidx],
@@ -464,20 +464,20 @@ static void FNAME(uncompress_row0)(Encoder *encoder, Channel *channel,
 
         channel->state.wmidx++;
         set_wm_trigger(&channel->state);
-        channel->state.wmileft = wminext;
+        channel->state.wmileft = WMINEXT;
     }
 
     if (width) {
         FNAME(uncompress_row0_seg)(encoder, channel, pos, correlate_row, cur_row, pos + width,
                                    bppmask[channel->state.wmidx], bpc, bpc_mask);
-        if (wmimax > (int)channel->state.wmidx) {
+        if (WMIMAX > (int)channel->state.wmidx) {
             channel->state.wmileft -= width;
         }
     }
 
-    spice_assert((int)channel->state.wmidx <= wmimax);
+    spice_assert((int)channel->state.wmidx <= WMIMAX);
     spice_assert(channel->state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(WMINEXT > 0);
 }
 
 static void FNAME(uncompress_row_seg)(Encoder *encoder, Channel *channel,
@@ -592,7 +592,7 @@ static void FNAME(uncompress_row)(Encoder *encoder, Channel *channel,
     BYTE * const correlate_row = channel->correlate_row;
     unsigned int pos = 0;
 
-    while ((wmimax > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
+    while ((WMIMAX > (int)channel->state.wmidx) && (channel->state.wmileft <= width)) {
         if (channel->state.wmileft) {
             FNAME(uncompress_row_seg)(encoder, channel, correlate_row, prev_row, cur_row, pos,
                                       pos + channel->state.wmileft, bpc, bpc_mask);
@@ -602,20 +602,20 @@ static void FNAME(uncompress_row)(Encoder *encoder, Channel *channel,
 
         channel->state.wmidx++;
         set_wm_trigger(&channel->state);
-        channel->state.wmileft = wminext;
+        channel->state.wmileft = WMINEXT;
     }
 
     if (width) {
         FNAME(uncompress_row_seg)(encoder, channel, correlate_row, prev_row, cur_row, pos,
                                   pos + width, bpc, bpc_mask);
-        if (wmimax > (int)channel->state.wmidx) {
+        if (WMIMAX > (int)channel->state.wmidx) {
             channel->state.wmileft -= width;
         }
     }
 
-    spice_assert((int)channel->state.wmidx <= wmimax);
+    spice_assert((int)channel->state.wmidx <= WMIMAX);
     spice_assert(channel->state.wmidx <= 32);
-    spice_assert(wminext > 0);
+    spice_assert(WMINEXT > 0);
 }
 
 #undef PIXEL
-- 
2.13.0



More information about the Spice-devel mailing list