Commit 8e0446c6363f9b2f3dc2bfc003fc180046ef7bd5

Authored by KMG
2 parents 71544366 a32aebd6
Exists in v2

Merge branch 'wip-warnings-v2' into 'v2'

add -Wsign-compare and address the warnings

See merge request !13
src/Makefile.am
... ... @@ -4,7 +4,7 @@
4 4 AUTOMAKE_OPTIONS = subdir-objects
5 5  
6 6 AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
7   -AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC
  7 +AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC -Wsign-compare
8 8  
9 9 lib_LTLIBRARIES = libgf_complete.la
10 10 libgf_complete_la_SOURCES = gf.c gf_method.c gf_wgen.c gf_w4.c gf_w8.c gf_w16.c gf_w32.c \
... ...
src/gf.c
... ... @@ -119,7 +119,7 @@ void gf_error()
119 119 uint64_t gf_composite_get_default_poly(gf_t *base)
120 120 {
121 121 gf_internal_t *h;
122   - int rv;
  122 + uint64_t rv;
123 123  
124 124 h = (gf_internal_t *) base->scratch;
125 125 if (h->w == 4) {
... ... @@ -584,7 +584,7 @@ uint32_t gf_bitmatrix_inverse(uint32_t y, int w, uint32_t pp)
584 584 uint32_t mat[32], inv[32], mask;
585 585 int i;
586 586  
587   - mask = (w == 32) ? 0xffffffff : (1 << w) - 1;
  587 + mask = (w == 32) ? 0xffffffff : ((uint32_t)1 << w) - 1;
588 588 for (i = 0; i < w; i++) {
589 589 mat[i] = y;
590 590  
... ...
src/gf_w128.c
... ... @@ -49,7 +49,7 @@ void
49 49 gf_w128_multiply_region_from_single(gf_t *gf, void *src, void *dest, gf_val_128_t val, int bytes,
50 50 int xor)
51 51 {
52   - int i;
  52 + uint32_t i;
53 53 gf_val_128_t s128;
54 54 gf_val_128_t d128;
55 55 uint64_t c128[2];
... ... @@ -87,7 +87,7 @@ void
87 87 gf_w128_clm_multiply_region_from_single(gf_t *gf, void *src, void *dest, gf_val_128_t val, int bytes,
88 88 int xor)
89 89 {
90   - int i;
  90 + uint32_t i;
91 91 gf_val_128_t s128;
92 92 gf_val_128_t d128;
93 93 gf_region_data rd;
... ...
src/gf_w16.c
... ... @@ -1218,7 +1218,7 @@ int gf_w16_split_init(gf_t *gf)
1218 1218 struct gf_w16_split_8_8_data *d8;
1219 1219 int i, j, exp, issse3;
1220 1220 int isneon = 0;
1221   - uint32_t p, basep;
  1221 + uint32_t p, basep, tmp;
1222 1222  
1223 1223 h = (gf_internal_t *) gf->scratch;
1224 1224  
... ... @@ -1253,7 +1253,8 @@ int gf_w16_split_init(gf_t *gf)
1253 1253 if (j&1) {
1254 1254 d8->tables[exp][i][j] = d8->tables[exp][i][j^1] ^ p;
1255 1255 } else {
1256   - d8->tables[exp][i][j] = GF_MULTBY_TWO(d8->tables[exp][i][j>>1]);
  1256 + tmp = d8->tables[exp][i][j>>1];
  1257 + d8->tables[exp][i][j] = GF_MULTBY_TWO(tmp);
1257 1258 }
1258 1259 }
1259 1260 }
... ...
src/gf_w32.c
... ... @@ -50,7 +50,7 @@ void
50 50 gf_w32_multiply_region_from_single(gf_t *gf, void *src, void *dest, uint32_t val, int bytes, int
51 51 xor)
52 52 {
53   - int i;
  53 + uint32_t i;
54 54 uint32_t *s32;
55 55 uint32_t *d32;
56 56  
... ... @@ -75,7 +75,7 @@ void
75 75 gf_w32_clm_multiply_region_from_single_2(gf_t *gf, void *src, void *dest, uint32_t val, int bytes, int xor)
76 76 {
77 77  
78   - int i;
  78 + uint32_t i;
79 79 uint32_t *s32;
80 80 uint32_t *d32;
81 81  
... ... @@ -125,7 +125,7 @@ void
125 125 gf_w32_clm_multiply_region_from_single_3(gf_t *gf, void *src, void *dest, uint32_t val, int bytes, int xor)
126 126 {
127 127  
128   - int i;
  128 + uint32_t i;
129 129 uint32_t *s32;
130 130 uint32_t *d32;
131 131  
... ... @@ -178,7 +178,7 @@ static
178 178 void
179 179 gf_w32_clm_multiply_region_from_single_4(gf_t *gf, void *src, void *dest, uint32_t val, int bytes, int xor)
180 180 {
181   - int i;
  181 + uint32_t i;
182 182 uint32_t *s32;
183 183 uint32_t *d32;
184 184  
... ... @@ -389,7 +389,7 @@ void
389 389 gf_w32_cfmgk_multiply_region_from_single(gf_t *gf, void *src, void *dest, uint32_t val, int bytes, int xor)
390 390 {
391 391  
392   - int i;
  392 + uint32_t i;
393 393 uint32_t *s32;
394 394 uint32_t *d32;
395 395  
... ... @@ -666,12 +666,12 @@ static
666 666 void
667 667 gf_w32_group_set_shift_tables(uint32_t *shift, uint32_t val, gf_internal_t *h)
668 668 {
669   - int i;
  669 + uint32_t i;
670 670 uint32_t j;
671 671  
672 672 shift[0] = 0;
673 673  
674   - for (i = 1; i < (1 << h->arg1); i <<= 1) {
  674 + for (i = 1; i < ((uint32_t)1 << h->arg1); i <<= 1) {
675 675 for (j = 0; j < i; j++) shift[i|j] = shift[j]^val;
676 676 if (val & GF_FIRST_BIT) {
677 677 val <<= 1;
... ... @@ -2375,7 +2375,7 @@ int gf_w32_group_init(gf_t *gf)
2375 2375 uint32_t i, j, p, index;
2376 2376 struct gf_w32_group_data *gd;
2377 2377 gf_internal_t *h = (gf_internal_t *) gf->scratch;
2378   - int g_r, g_s;
  2378 + uint32_t g_r, g_s;
2379 2379  
2380 2380 g_s = h->arg1;
2381 2381 g_r = h->arg2;
... ... @@ -2393,7 +2393,7 @@ int gf_w32_group_init(gf_t *gf)
2393 2393 gd->tshift = ((gd->tshift-1)/g_r) * g_r;
2394 2394  
2395 2395 gd->reduce[0] = 0;
2396   - for (i = 0; i < (1 << g_r); i++) {
  2396 + for (i = 0; i < ((uint32_t)1 << g_r); i++) {
2397 2397 p = 0;
2398 2398 index = 0;
2399 2399 for (j = 0; j < g_r; j++) {
... ...
src/gf_w64.c
... ... @@ -35,7 +35,7 @@ void
35 35 gf_w64_multiply_region_from_single(gf_t *gf, void *src, void *dest, gf_val_64_t val, int bytes, int
36 36 xor)
37 37 {
38   - int i;
  38 + uint32_t i;
39 39 gf_val_64_t *s64;
40 40 gf_val_64_t *d64;
41 41  
... ... @@ -733,7 +733,7 @@ static
733 733 void
734 734 gf_w64_group_set_shift_tables(uint64_t *shift, uint64_t val, gf_internal_t *h)
735 735 {
736   - int i;
  736 + uint64_t i;
737 737 uint64_t j;
738 738 uint64_t one = 1;
739 739 int g_s;
... ... @@ -741,7 +741,7 @@ gf_w64_group_set_shift_tables(uint64_t *shift, uint64_t val, gf_internal_t *h)
741 741 g_s = h->arg1;
742 742 shift[0] = 0;
743 743  
744   - for (i = 1; i < (1 << g_s); i <<= 1) {
  744 + for (i = 1; i < ((uint64_t)1 << g_s); i <<= 1) {
745 745 for (j = 0; j < i; j++) shift[i|j] = shift[j]^val;
746 746 if (val & (one << 63)) {
747 747 val <<= 1;
... ... @@ -767,7 +767,7 @@ gf_w64_group_multiply(gf_t *gf, gf_val_64_t a, gf_val_64_t b)
767 767 gd = (struct gf_w64_group_data *) h->private;
768 768 gf_w64_group_set_shift_tables(gd->shift, b, h);
769 769  
770   - mask = ((1 << g_s) - 1);
  770 + mask = (((uint64_t)1 << g_s) - 1);
771 771 top = 0;
772 772 bot = gd->shift[a&mask];
773 773 a >>= g_s;
... ... @@ -791,7 +791,7 @@ gf_w64_group_multiply(gf_t *gf, gf_val_64_t a, gf_val_64_t b)
791 791  
792 792 lshift = ((lshift-1) / g_r) * g_r;
793 793 rshift = 64 - lshift;
794   - mask = (1 << g_r) - 1;
  794 + mask = ((uint64_t)1 << g_r) - 1;
795 795 while (lshift >= 0) {
796 796 tp = gd->reduce[(top >> lshift) & mask];
797 797 top ^= (tp >> rshift);
... ... @@ -840,8 +840,8 @@ void gf_w64_group_multiply_region(gf_t *gf, void *src, void *dest, gf_val_64_t v
840 840 d64 = (uint64_t *) rd.d_start;
841 841 dtop = (uint64_t *) rd.d_top;
842 842  
843   - smask = (1 << g_s) - 1;
844   - rmask = (1 << g_r) - 1;
  843 + smask = ((uint64_t)1 << g_s) - 1;
  844 + rmask = ((uint64_t)1 << g_r) - 1;
845 845  
846 846 while (d64 < dtop) {
847 847 a64 = *s64;
... ... @@ -984,7 +984,7 @@ int gf_w64_group_init(gf_t *gf)
984 984 uint64_t i, j, p, index;
985 985 struct gf_w64_group_data *gd;
986 986 gf_internal_t *h = (gf_internal_t *) gf->scratch;
987   - int g_r, g_s;
  987 + uint64_t g_r, g_s;
988 988  
989 989 g_s = h->arg1;
990 990 g_r = h->arg2;
... ... @@ -994,7 +994,7 @@ int gf_w64_group_init(gf_t *gf)
994 994 gd->reduce = gd->shift + (1 << g_s);
995 995  
996 996 gd->reduce[0] = 0;
997   - for (i = 0; i < (1 << g_r); i++) {
  997 + for (i = 0; i < ((uint64_t)1 << g_r); i++) {
998 998 p = 0;
999 999 index = 0;
1000 1000 for (j = 0; j < g_r; j++) {
... ...
src/gf_wgen.c
... ... @@ -166,10 +166,10 @@ gf_wgen_shift_multiply (gf_t *gf, uint32_t a32, uint32_t b32)
166 166  
167 167 product = 0;
168 168  
169   - for (i = 0; i < h->w; i++) {
  169 + for (i = 0; i < (uint64_t)h->w; i++) {
170 170 if (a & (one << i)) product ^= (b << i);
171 171 }
172   - for (i = h->w*2-1; i >= h->w; i--) {
  172 + for (i = h->w*2-1; i >= (uint64_t)h->w; i--) {
173 173 if (product & (one << i)) product ^= (pp << (i-h->w));
174 174 }
175 175 return product;
... ... @@ -256,7 +256,7 @@ static
256 256 void
257 257 gf_wgen_group_set_shift_tables(uint32_t *shift, uint32_t val, gf_internal_t *h)
258 258 {
259   - int i;
  259 + uint32_t i;
260 260 uint32_t j;
261 261 int g_s;
262 262  
... ... @@ -268,7 +268,7 @@ gf_wgen_group_set_shift_tables(uint32_t *shift, uint32_t val, gf_internal_t *h)
268 268  
269 269 shift[0] = 0;
270 270  
271   - for (i = 1; i < (1 << g_s); i <<= 1) {
  271 + for (i = 1; i < ((uint32_t)1 << g_s); i <<= 1) {
272 272 for (j = 0; j < i; j++) shift[i|j] = shift[j]^val;
273 273 if (val & (1 << (h->w-1))) {
274 274 val <<= 1;
... ... @@ -417,7 +417,7 @@ int gf_wgen_group_init(gf_t *gf)
417 417 uint32_t i, j, p, index;
418 418 struct gf_wgen_group_data *gd;
419 419 gf_internal_t *h = (gf_internal_t *) gf->scratch;
420   - int g_s, g_r;
  420 + uint32_t g_s, g_r;
421 421  
422 422 if (h->mult_type == GF_MULT_DEFAULT) {
423 423 g_s = 2;
... ... @@ -440,7 +440,7 @@ int gf_wgen_group_init(gf_t *gf)
440 440 gd->tshift = ((gd->tshift-1)/g_r) * g_r;
441 441  
442 442 gd->reduce[0] = 0;
443   - for (i = 0; i < (1 << g_r); i++) {
  443 + for (i = 0; i < ((uint32_t)1 << g_r); i++) {
444 444 p = 0;
445 445 index = 0;
446 446 for (j = 0; j < g_r; j++) {
... ... @@ -504,15 +504,15 @@ int gf_wgen_table_8_init(gf_t *gf)
504 504 std->mult = &(std->base);
505 505 std->div = std->mult + ((1<<h->w)*(1<<h->w));
506 506  
507   - for (a = 0; a < (1 << w); a++) {
  507 + for (a = 0; a < ((uint32_t)1 << w); a++) {
508 508 std->mult[a] = 0;
509 509 std->mult[a<<w] = 0;
510 510 std->div[a] = 0;
511 511 std->div[a<<w] = 0;
512 512 }
513 513  
514   - for (a = 1; a < (1 << w); a++) {
515   - for (b = 1; b < (1 << w); b++) {
  514 + for (a = 1; a < ((uint32_t)1 << w); a++) {
  515 + for (b = 1; b < ((uint32_t)1 << w); b++) {
516 516 p = gf_wgen_shift_multiply(gf, a, b);
517 517 std->mult[(a<<w)|b] = p;
518 518 std->div[(p<<w)|a] = b;
... ... @@ -565,15 +565,15 @@ int gf_wgen_table_16_init(gf_t *gf)
565 565 std->mult = &(std->base);
566 566 std->div = std->mult + ((1<<h->w)*(1<<h->w));
567 567  
568   - for (a = 0; a < (1 << w); a++) {
  568 + for (a = 0; a < ((uint32_t)1 << w); a++) {
569 569 std->mult[a] = 0;
570 570 std->mult[a<<w] = 0;
571 571 std->div[a] = 0;
572 572 std->div[a<<w] = 0;
573 573 }
574 574  
575   - for (a = 1; a < (1 << w); a++) {
576   - for (b = 1; b < (1 << w); b++) {
  575 + for (a = 1; a < ((uint32_t)1 << w); a++) {
  576 + for (b = 1; b < ((uint32_t)1 << w); b++) {
577 577 p = gf_wgen_shift_multiply(gf, a, b);
578 578 std->mult[(a<<w)|b] = p;
579 579 std->div[(p<<w)|a] = b;
... ... @@ -649,11 +649,11 @@ int gf_wgen_log_8_init(gf_t *gf)
649 649 std->anti = std->log + (1<<h->w);
650 650 std->danti = std->anti + (1<<h->w)-1;
651 651  
652   - for (i = 0; i < (1 << w); i++)
  652 + for (i = 0; i < ((uint32_t)1 << w); i++)
653 653 std->log[i] = 0;
654 654  
655 655 a = 1;
656   - for(i=0; i < (1<<w)-1; i++)
  656 + for(i=0; i < ((uint32_t)1<<w)-1; i++)
657 657 {
658 658 if (std->log[a] != 0) check = 1;
659 659 std->log[a] = i;
... ... @@ -724,11 +724,11 @@ int gf_wgen_log_16_init(gf_t *gf)
724 724 std->anti = std->log + (1<<h->w);
725 725 std->danti = std->anti + (1<<h->w)-1;
726 726  
727   - for (i = 0; i < (1 << w); i++)
  727 + for (i = 0; i < ((uint32_t)1 << w); i++)
728 728 std->log[i] = 0;
729 729  
730 730 a = 1;
731   - for(i=0; i < (1<<w)-1; i++)
  731 + for(i=0; i < ((uint32_t)1<<w)-1; i++)
732 732 {
733 733 if (std->log[a] != 0) check = 1;
734 734 std->log[a] = i;
... ... @@ -800,11 +800,11 @@ int gf_wgen_log_32_init(gf_t *gf)
800 800 std->anti = std->log + (1<<h->w);
801 801 std->danti = std->anti + (1<<h->w)-1;
802 802  
803   - for (i = 0; i < (1 << w); i++)
  803 + for (i = 0; i < ((uint32_t)1 << w); i++)
804 804 std->log[i] = 0;
805 805  
806 806 a = 1;
807   - for(i=0; i < (1<<w)-1; i++)
  807 + for(i=0; i < ((uint32_t)1<<w)-1; i++)
808 808 {
809 809 if (std->log[a] != 0) check = 1;
810 810 std->log[a] = i;
... ...