diff mbox series

[v5,3/3] timer/exynos4210_mct: Remove redundant statement in exynos4210_mct_write()

Message ID 20200325025919.21316-4-kuhn.chenqun@huawei.com
State New
Headers show
Series redundant code: Fix warnings reported by Clang static code analyzer | expand

Commit Message

Chenqun (kuhn) March 25, 2020, 2:59 a.m. UTC
Clang static code analyzer show warning:
hw/timer/exynos4210_mct.c:1370:9: warning: Value stored to 'index' is never read
        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
        ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hw/timer/exynos4210_mct.c:1399:9: warning: Value stored to 'index' is never read
        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
        ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hw/timer/exynos4210_mct.c:1441:9: warning: Value stored to 'index' is never read
        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
        ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
---
Cc: Igor Mitsyanko <i.mitsyanko@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
---
 hw/timer/exynos4210_mct.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

Philippe Mathieu-Daudé March 25, 2020, 12:16 p.m. UTC | #1
On 3/25/20 3:59 AM, Chen Qun wrote:
> Clang static code analyzer show warning:
> hw/timer/exynos4210_mct.c:1370:9: warning: Value stored to 'index' is never read
>          index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
>          ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> hw/timer/exynos4210_mct.c:1399:9: warning: Value stored to 'index' is never read
>          index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
>          ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> hw/timer/exynos4210_mct.c:1441:9: warning: Value stored to 'index' is never read
>          index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
>          ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
> Cc: Igor Mitsyanko <i.mitsyanko@gmail.com>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/timer/exynos4210_mct.c | 4 ----
>   1 file changed, 4 deletions(-)
> 
> diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
> index 944120aea5..570cf7075b 100644
> --- a/hw/timer/exynos4210_mct.c
> +++ b/hw/timer/exynos4210_mct.c
> @@ -1367,7 +1367,6 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset,
>   
>       case L0_TCNTB: case L1_TCNTB:
>           lt_i = GET_L_TIMER_IDX(offset);
> -        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
>   
>           /*
>            * TCNTB is updated to internal register only after CNT expired.
> @@ -1396,7 +1395,6 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset,
>   
>       case L0_ICNTB: case L1_ICNTB:
>           lt_i = GET_L_TIMER_IDX(offset);
> -        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
>   
>           s->l_timer[lt_i].reg.wstat |= L_WSTAT_ICNTB_WRITE;
>           s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] = value &
> @@ -1438,8 +1436,6 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset,
>   
>       case L0_FRCNTB: case L1_FRCNTB:
>           lt_i = GET_L_TIMER_IDX(offset);
> -        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
> -
>           DPRINTF("local timer[%d] FRCNTB write %llx\n", lt_i, value);
>   
>           s->l_timer[lt_i].reg.wstat |= L_WSTAT_FRCCNTB_WRITE;
>
Philippe Mathieu-Daudé March 25, 2020, 12:20 p.m. UTC | #2
On 3/25/20 1:16 PM, Philippe Mathieu-Daudé wrote:
> On 3/25/20 3:59 AM, Chen Qun wrote:
>> Clang static code analyzer show warning:
>> hw/timer/exynos4210_mct.c:1370:9: warning: Value stored to 'index' is 
>> never read
>>          index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
>>          ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> hw/timer/exynos4210_mct.c:1399:9: warning: Value stored to 'index' is 
>> never read
>>          index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
>>          ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> hw/timer/exynos4210_mct.c:1441:9: warning: Value stored to 'index' is 
>> never read
>>          index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
>>          ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Reported-by: Euler Robot <euler.robot@huawei.com>
>> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
>> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Oh and per 
https://www.mail-archive.com/qemu-devel@nongnu.org/msg691384.html:

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

> 
>> ---
>> Cc: Igor Mitsyanko <i.mitsyanko@gmail.com>
>> Cc: Peter Maydell <peter.maydell@linaro.org>
>> ---
>>   hw/timer/exynos4210_mct.c | 4 ----
>>   1 file changed, 4 deletions(-)
>>
>> diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
>> index 944120aea5..570cf7075b 100644
>> --- a/hw/timer/exynos4210_mct.c
>> +++ b/hw/timer/exynos4210_mct.c
>> @@ -1367,7 +1367,6 @@ static void exynos4210_mct_write(void *opaque, 
>> hwaddr offset,
>>       case L0_TCNTB: case L1_TCNTB:
>>           lt_i = GET_L_TIMER_IDX(offset);
>> -        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
>>           /*
>>            * TCNTB is updated to internal register only after CNT 
>> expired.
>> @@ -1396,7 +1395,6 @@ static void exynos4210_mct_write(void *opaque, 
>> hwaddr offset,
>>       case L0_ICNTB: case L1_ICNTB:
>>           lt_i = GET_L_TIMER_IDX(offset);
>> -        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
>>           s->l_timer[lt_i].reg.wstat |= L_WSTAT_ICNTB_WRITE;
>>           s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] = value &
>> @@ -1438,8 +1436,6 @@ static void exynos4210_mct_write(void *opaque, 
>> hwaddr offset,
>>       case L0_FRCNTB: case L1_FRCNTB:
>>           lt_i = GET_L_TIMER_IDX(offset);
>> -        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
>> -
>>           DPRINTF("local timer[%d] FRCNTB write %llx\n", lt_i, value);
>>           s->l_timer[lt_i].reg.wstat |= L_WSTAT_FRCCNTB_WRITE;
>>
diff mbox series

Patch

diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
index 944120aea5..570cf7075b 100644
--- a/hw/timer/exynos4210_mct.c
+++ b/hw/timer/exynos4210_mct.c
@@ -1367,7 +1367,6 @@  static void exynos4210_mct_write(void *opaque, hwaddr offset,
 
     case L0_TCNTB: case L1_TCNTB:
         lt_i = GET_L_TIMER_IDX(offset);
-        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
 
         /*
          * TCNTB is updated to internal register only after CNT expired.
@@ -1396,7 +1395,6 @@  static void exynos4210_mct_write(void *opaque, hwaddr offset,
 
     case L0_ICNTB: case L1_ICNTB:
         lt_i = GET_L_TIMER_IDX(offset);
-        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
 
         s->l_timer[lt_i].reg.wstat |= L_WSTAT_ICNTB_WRITE;
         s->l_timer[lt_i].reg.cnt[L_REG_CNT_ICNTB] = value &
@@ -1438,8 +1436,6 @@  static void exynos4210_mct_write(void *opaque, hwaddr offset,
 
     case L0_FRCNTB: case L1_FRCNTB:
         lt_i = GET_L_TIMER_IDX(offset);
-        index = GET_L_TIMER_CNT_REG_IDX(offset, lt_i);
-
         DPRINTF("local timer[%d] FRCNTB write %llx\n", lt_i, value);
 
         s->l_timer[lt_i].reg.wstat |= L_WSTAT_FRCCNTB_WRITE;