From da671b490833332afb72e02480b9100535864cbf Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Wed, 17 Jun 2015 10:43:38 +0200 Subject: src/gf_w64.c: remove dead code Fix for Coverity issue: CID 1297852 (#1 of 1): 'Constant'; variable guards dead code (DEADCODE) dead_error_begin: Execution cannot reach this statement: fprintf(stderr, "Code conta.... Local variable no_default_flag is assigned only once, to a constant value, making it effectively constant throughout its scope. If this is not the intent, examine the logic to see if there is a missing assignment that would make no_default_flag not remain constant. Signed-off-by: Danny Al-Gaaf --- src/gf_w64.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/gf_w64.c b/src/gf_w64.c index 6e75f5e..91f53d6 100644 --- a/src/gf_w64.c +++ b/src/gf_w64.c @@ -2153,7 +2153,6 @@ int gf_w64_scratch_size(int mult_type, int region_type, int divide_type, int arg int gf_w64_init(gf_t *gf) { gf_internal_t *h; - int no_default_flag = 0; h = (gf_internal_t *) gf->scratch; @@ -2168,10 +2167,6 @@ int gf_w64_init(gf_t *gf) } else { h->prim_poly = 0x1b; } - if (no_default_flag == 1) { - fprintf(stderr,"Code contains no default irreducible polynomial for given base field\n"); - return 0; - } } gf->multiply.w64 = NULL; -- cgit v1.2.1 From 7972291e1f1fb68d05332cccd46a738b0d83b1be Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Wed, 17 Jun 2015 10:46:44 +0200 Subject: src/gf_w128.c: remove dead code and unused variable Fix for Coverity issue: CID 1297812 (#1 of 1): Constant variable guards dead code (DEADCODE) dead_error_begin: Execution cannot reach this statement: fprintf(stderr, "Code conta.... Local variable no_default_flag is assigned only once, to a constant value, making it effectively constant throughout its scope. If this is not the intent, examine the logic to see if there is a missing assignment that would make no_default_flag not remain constant. Signed-off-by: Danny Al-Gaaf --- src/gf_w128.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/gf_w128.c b/src/gf_w128.c index 190f6b0..81999cb 100644 --- a/src/gf_w128.c +++ b/src/gf_w128.c @@ -1724,7 +1724,6 @@ int gf_w128_scratch_size(int mult_type, int region_type, int divide_type, int ar int gf_w128_init(gf_t *gf) { gf_internal_t *h; - int no_default_flag = 0; h = (gf_internal_t *) gf->scratch; @@ -1737,10 +1736,6 @@ int gf_w128_init(gf_t *gf) } else { h->prim_poly = 0x87; /* Omitting the leftmost 1 as in w=32 */ } - if (no_default_flag == 1) { - fprintf(stderr,"Code contains no default irreducible polynomial for given base field\n"); - return 0; - } } gf->multiply.w128 = NULL; -- cgit v1.2.1 From 98e5e37159f4c7634305aa65c9bc98a36488a4a9 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 18 Jun 2015 08:55:49 +0200 Subject: gf_w64.c: fix integer overflow Fix for Coverity issue (from Ceph): CID 1193086 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) overflow_before_widen: Potentially overflowing expression 1 << g_r with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type uint64_t (64 bits, unsigned). Signed-off-by: Danny Al-Gaaf --- src/gf_w64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gf_w64.c b/src/gf_w64.c index 91f53d6..74e5e9e 100644 --- a/src/gf_w64.c +++ b/src/gf_w64.c @@ -994,7 +994,7 @@ int gf_w64_group_init(gf_t *gf) gd->reduce = gd->shift + (1 << g_s); gd->reduce[0] = 0; - for (i = 0; i < (1 << g_r); i++) { + for (i = 0; i < ((uint64_t)1 << g_r); i++) { p = 0; index = 0; for (j = 0; j < g_r; j++) { -- cgit v1.2.1 From e127bb1fb9b1025094a0e0ce50d2e44c38c4e97f Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 18 Jun 2015 08:58:20 +0200 Subject: gf_w64.c: fix integer overflow Fix for Coverity issue (from Ceph): CID 1193087 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) overflow_before_widen: Potentially overflowing expression 1 << g_r with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type uint64_t (64 bits, unsigned). Signed-off-by: Danny Al-Gaaf --- src/gf_w64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gf_w64.c b/src/gf_w64.c index 74e5e9e..c8356b8 100644 --- a/src/gf_w64.c +++ b/src/gf_w64.c @@ -791,7 +791,7 @@ gf_w64_group_multiply(gf_t *gf, gf_val_64_t a, gf_val_64_t b) lshift = ((lshift-1) / g_r) * g_r; rshift = 64 - lshift; - mask = (1 << g_r) - 1; + mask = ((uint64_t)1 << g_r) - 1; while (lshift >= 0) { tp = gd->reduce[(top >> lshift) & mask]; top ^= (tp >> rshift); -- cgit v1.2.1 From 1aef8694bc62a053e35cc1c74c67f1d15d8d1b6a Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 18 Jun 2015 09:00:03 +0200 Subject: gf_w64.c: fix integer overflow Fix for Coverity issue (from Ceph): CID 1193088 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) overflow_before_widen: Potentially overflowing expression 1 << g_s with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type uint64_t (64 bits, unsigned). Signed-off-by: Danny Al-Gaaf --- src/gf_w64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gf_w64.c b/src/gf_w64.c index c8356b8..7f9f965 100644 --- a/src/gf_w64.c +++ b/src/gf_w64.c @@ -767,7 +767,7 @@ gf_w64_group_multiply(gf_t *gf, gf_val_64_t a, gf_val_64_t b) gd = (struct gf_w64_group_data *) h->private; gf_w64_group_set_shift_tables(gd->shift, b, h); - mask = ((1 << g_s) - 1); + mask = (((uint64_t)1 << g_s) - 1); top = 0; bot = gd->shift[a&mask]; a >>= g_s; -- cgit v1.2.1 From 2f6db512fb83f2d8e84e8097ebd2595c6ec8f8eb Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 18 Jun 2015 09:01:37 +0200 Subject: gf_w64.c: fix integer overflow Fix for Coverity issue (from Ceph): CID 1193089 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) overflow_before_widen: Potentially overflowing expression 1 << g_r with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type uint64_t (64 bits, unsigned). CID 1193090 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) overflow_before_widen: Potentially overflowing expression 1 << g_s with type int (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type uint64_t (64 bits, unsigned). Signed-off-by: Danny Al-Gaaf --- src/gf_w64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gf_w64.c b/src/gf_w64.c index 7f9f965..de231db 100644 --- a/src/gf_w64.c +++ b/src/gf_w64.c @@ -840,8 +840,8 @@ void gf_w64_group_multiply_region(gf_t *gf, void *src, void *dest, gf_val_64_t v d64 = (uint64_t *) rd.d_start; dtop = (uint64_t *) rd.d_top; - smask = (1 << g_s) - 1; - rmask = (1 << g_r) - 1; + smask = ((uint64_t)1 << g_s) - 1; + rmask = ((uint64_t)1 << g_r) - 1; while (d64 < dtop) { a64 = *s64; -- cgit v1.2.1