Commit af22f913ed60310516f6ab4c08389884b45338a4

Authored by Loic Dachary
2 parents 5f31e271 2f6db512
Exists in master and in 1 other branch v3

Merge branch 'wip-da-SCA-coverity' into 'master'

Fix issues found by Coverity in the Ceph project

Remove dead code and fix potential integer overflow issues

See merge request !12
Showing 2 changed files with 5 additions and 15 deletions   Show diff stats
@@ -1724,7 +1724,6 @@ int gf_w128_scratch_size(int mult_type, int region_type, int divide_type, int ar @@ -1724,7 +1724,6 @@ int gf_w128_scratch_size(int mult_type, int region_type, int divide_type, int ar
1724 int gf_w128_init(gf_t *gf) 1724 int gf_w128_init(gf_t *gf)
1725 { 1725 {
1726 gf_internal_t *h; 1726 gf_internal_t *h;
1727 - int no_default_flag = 0;  
1728 1727
1729 h = (gf_internal_t *) gf->scratch; 1728 h = (gf_internal_t *) gf->scratch;
1730 1729
@@ -1737,10 +1736,6 @@ int gf_w128_init(gf_t *gf) @@ -1737,10 +1736,6 @@ int gf_w128_init(gf_t *gf)
1737 } else { 1736 } else {
1738 h->prim_poly = 0x87; /* Omitting the leftmost 1 as in w=32 */ 1737 h->prim_poly = 0x87; /* Omitting the leftmost 1 as in w=32 */
1739 } 1738 }
1740 - if (no_default_flag == 1) {  
1741 - fprintf(stderr,"Code contains no default irreducible polynomial for given base field\n");  
1742 - return 0;  
1743 - }  
1744 } 1739 }
1745 1740
1746 gf->multiply.w128 = NULL; 1741 gf->multiply.w128 = NULL;
@@ -767,7 +767,7 @@ gf_w64_group_multiply(gf_t *gf, gf_val_64_t a, gf_val_64_t b) @@ -767,7 +767,7 @@ gf_w64_group_multiply(gf_t *gf, gf_val_64_t a, gf_val_64_t b)
767 gd = (struct gf_w64_group_data *) h->private; 767 gd = (struct gf_w64_group_data *) h->private;
768 gf_w64_group_set_shift_tables(gd->shift, b, h); 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 top = 0; 771 top = 0;
772 bot = gd->shift[a&mask]; 772 bot = gd->shift[a&mask];
773 a >>= g_s; 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,7 +791,7 @@ gf_w64_group_multiply(gf_t *gf, gf_val_64_t a, gf_val_64_t b)
791 791
792 lshift = ((lshift-1) / g_r) * g_r; 792 lshift = ((lshift-1) / g_r) * g_r;
793 rshift = 64 - lshift; 793 rshift = 64 - lshift;
794 - mask = (1 << g_r) - 1; 794 + mask = ((uint64_t)1 << g_r) - 1;
795 while (lshift >= 0) { 795 while (lshift >= 0) {
796 tp = gd->reduce[(top >> lshift) & mask]; 796 tp = gd->reduce[(top >> lshift) & mask];
797 top ^= (tp >> rshift); 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,8 +840,8 @@ void gf_w64_group_multiply_region(gf_t *gf, void *src, void *dest, gf_val_64_t v
840 d64 = (uint64_t *) rd.d_start; 840 d64 = (uint64_t *) rd.d_start;
841 dtop = (uint64_t *) rd.d_top; 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 while (d64 < dtop) { 846 while (d64 < dtop) {
847 a64 = *s64; 847 a64 = *s64;
@@ -994,7 +994,7 @@ int gf_w64_group_init(gf_t *gf) @@ -994,7 +994,7 @@ int gf_w64_group_init(gf_t *gf)
994 gd->reduce = gd->shift + (1 << g_s); 994 gd->reduce = gd->shift + (1 << g_s);
995 995
996 gd->reduce[0] = 0; 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 p = 0; 998 p = 0;
999 index = 0; 999 index = 0;
1000 for (j = 0; j < g_r; j++) { 1000 for (j = 0; j < g_r; j++) {
@@ -2153,7 +2153,6 @@ int gf_w64_scratch_size(int mult_type, int region_type, int divide_type, int arg @@ -2153,7 +2153,6 @@ int gf_w64_scratch_size(int mult_type, int region_type, int divide_type, int arg
2153 int gf_w64_init(gf_t *gf) 2153 int gf_w64_init(gf_t *gf)
2154 { 2154 {
2155 gf_internal_t *h; 2155 gf_internal_t *h;
2156 - int no_default_flag = 0;  
2157 2156
2158 h = (gf_internal_t *) gf->scratch; 2157 h = (gf_internal_t *) gf->scratch;
2159 2158
@@ -2168,10 +2167,6 @@ int gf_w64_init(gf_t *gf) @@ -2168,10 +2167,6 @@ int gf_w64_init(gf_t *gf)
2168 } else { 2167 } else {
2169 h->prim_poly = 0x1b; 2168 h->prim_poly = 0x1b;
2170 } 2169 }
2171 - if (no_default_flag == 1) {  
2172 - fprintf(stderr,"Code contains no default irreducible polynomial for given base field\n");  
2173 - return 0;  
2174 - }  
2175 } 2170 }
2176 2171
2177 gf->multiply.w64 = NULL; 2172 gf->multiply.w64 = NULL;