diff mbox

linux-generic: traffic-manager: fix integer handling issue

Message ID 1459142924-5083-1-git-send-email-bala.manoharan@linaro.org
State Superseded
Headers show

Commit Message

Balasubramanian Manoharan March 28, 2016, 5:28 a.m. UTC
Fixes: https://bugs.linaro.org/show_bug.cgi?id=2122

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
 platform/linux-generic/odp_timer_wheel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Bill Fischofer March 28, 2016, 2:21 p.m. UTC | #1
On Mon, Mar 28, 2016 at 12:28 AM, Balasubramanian Manoharan <
bala.manoharan@linaro.org> wrote:

> Fixes: https://bugs.linaro.org/show_bug.cgi?id=2122

>

> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

>


Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>



> ---

>  platform/linux-generic/odp_timer_wheel.c | 3 ++-

>  1 file changed, 2 insertions(+), 1 deletion(-)

>

> diff --git a/platform/linux-generic/odp_timer_wheel.c

> b/platform/linux-generic/odp_timer_wheel.c

> index 638edf4..8b8ca87 100644

> --- a/platform/linux-generic/odp_timer_wheel.c

> +++ b/platform/linux-generic/odp_timer_wheel.c

> @@ -167,7 +167,8 @@ static uint32_t _odp_internal_ilog2(uint64_t value)

>         uint32_t bit_shift;

>

>         for (bit_shift = 0; bit_shift < 64; bit_shift++) {

> -               pwr_of_2 = 1 << bit_shift;

> +               /* FIX: BUG2122 Coverity issue */

> +               pwr_of_2 = (uint64_t)1 << bit_shift;

>                 if (value == pwr_of_2)

>                         return bit_shift;

>                 else if (value < pwr_of_2)

> --

> 1.9.1

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> https://lists.linaro.org/mailman/listinfo/lng-odp

>
Maxim Uvarov March 28, 2016, 2:37 p.m. UTC | #2
On 03/28/16 08:28, Balasubramanian Manoharan wrote:
> Fixes: https://bugs.linaro.org/show_bug.cgi?id=2122
>
> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
> ---
>   platform/linux-generic/odp_timer_wheel.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/platform/linux-generic/odp_timer_wheel.c b/platform/linux-generic/odp_timer_wheel.c
> index 638edf4..8b8ca87 100644
> --- a/platform/linux-generic/odp_timer_wheel.c
> +++ b/platform/linux-generic/odp_timer_wheel.c
> @@ -167,7 +167,8 @@ static uint32_t _odp_internal_ilog2(uint64_t value)
>   	uint32_t bit_shift;
>   
>   	for (bit_shift = 0; bit_shift < 64; bit_shift++) {
> -		pwr_of_2 = 1 << bit_shift;
> +		/* FIX: BUG2122 Coverity issue */
> +		pwr_of_2 = (uint64_t)1 << bit_shift;
1. I think comment has to be removed.
2. 1ULL << bit_shift  - isn't it better?

Maxim.
>   		if (value == pwr_of_2)
>   			return bit_shift;
>   		else if (value < pwr_of_2)
Bill Fischofer March 28, 2016, 2:49 p.m. UTC | #3
+1 on Maxim's suggested changes.

On Mon, Mar 28, 2016 at 9:37 AM, Maxim Uvarov <maxim.uvarov@linaro.org>
wrote:

> On 03/28/16 08:28, Balasubramanian Manoharan wrote:

>

>> Fixes: https://bugs.linaro.org/show_bug.cgi?id=2122

>>

>> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

>> ---

>>   platform/linux-generic/odp_timer_wheel.c | 3 ++-

>>   1 file changed, 2 insertions(+), 1 deletion(-)

>>

>> diff --git a/platform/linux-generic/odp_timer_wheel.c

>> b/platform/linux-generic/odp_timer_wheel.c

>> index 638edf4..8b8ca87 100644

>> --- a/platform/linux-generic/odp_timer_wheel.c

>> +++ b/platform/linux-generic/odp_timer_wheel.c

>> @@ -167,7 +167,8 @@ static uint32_t _odp_internal_ilog2(uint64_t value)

>>         uint32_t bit_shift;

>>         for (bit_shift = 0; bit_shift < 64; bit_shift++) {

>> -               pwr_of_2 = 1 << bit_shift;

>> +               /* FIX: BUG2122 Coverity issue */

>> +               pwr_of_2 = (uint64_t)1 << bit_shift;

>>

> 1. I think comment has to be removed.

> 2. 1ULL << bit_shift  - isn't it better?

>

> Maxim.

>

>>                 if (value == pwr_of_2)

>>                         return bit_shift;

>>                 else if (value < pwr_of_2)

>>

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> https://lists.linaro.org/mailman/listinfo/lng-odp

>
diff mbox

Patch

diff --git a/platform/linux-generic/odp_timer_wheel.c b/platform/linux-generic/odp_timer_wheel.c
index 638edf4..8b8ca87 100644
--- a/platform/linux-generic/odp_timer_wheel.c
+++ b/platform/linux-generic/odp_timer_wheel.c
@@ -167,7 +167,8 @@  static uint32_t _odp_internal_ilog2(uint64_t value)
 	uint32_t bit_shift;
 
 	for (bit_shift = 0; bit_shift < 64; bit_shift++) {
-		pwr_of_2 = 1 << bit_shift;
+		/* FIX: BUG2122 Coverity issue */
+		pwr_of_2 = (uint64_t)1 << bit_shift;
 		if (value == pwr_of_2)
 			return bit_shift;
 		else if (value < pwr_of_2)