* [PATCH] ALSA: synth: emux: remove redundant test for r <= 13
@ 2017-11-14 17:26 Colin King
2017-11-17 11:06 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2017-11-14 17:26 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai, alsa-devel; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The calculation r = (3 - ((rate >> 6) & 3)) * 3 results in r being
0, 3, 6 or 9 and so the check (13 > r) is always true and hence we
can remove the redundant check and the else path.
Detected by CoverityScan, CID#744415 ("Logically dead code")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
sound/synth/emux/soundfont.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c
index 31a4ea94830e..0beb5a737c8b 100644
--- a/sound/synth/emux/soundfont.c
+++ b/sound/synth/emux/soundfont.c
@@ -858,10 +858,7 @@ calc_gus_envelope_time(int rate, int start, int end)
p = rate & 0x3f;
t = end - start;
if (t < 0) t = -t;
- if (13 > r)
- t = t << (13 - r);
- else
- t = t >> (r - 13);
+ t = t << (13 - r);
return (t * 10) / (p * 441);
}
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] ALSA: synth: emux: remove redundant test for r <= 13
2017-11-14 17:26 [PATCH] ALSA: synth: emux: remove redundant test for r <= 13 Colin King
@ 2017-11-17 11:06 ` Takashi Iwai
2017-11-17 11:07 ` Colin Ian King
0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2017-11-17 11:06 UTC (permalink / raw)
To: Colin King; +Cc: alsa-devel, Jaroslav Kysela, kernel-janitors, linux-kernel
On Tue, 14 Nov 2017 18:26:53 +0100,
Colin King wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> The calculation r = (3 - ((rate >> 6) & 3)) * 3 results in r being
> 0, 3, 6 or 9 and so the check (13 > r) is always true and hence we
> can remove the redundant check and the else path.
>
> Detected by CoverityScan, CID#744415 ("Logically dead code")
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
The calculation of t itself can be generic in case we may add a
support greater than the current r, so I don't think it's so much
beneficial with this code reduction. Better to keep the code as
reference.
thanks,
Takashi
> ---
> sound/synth/emux/soundfont.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c
> index 31a4ea94830e..0beb5a737c8b 100644
> --- a/sound/synth/emux/soundfont.c
> +++ b/sound/synth/emux/soundfont.c
> @@ -858,10 +858,7 @@ calc_gus_envelope_time(int rate, int start, int end)
> p = rate & 0x3f;
> t = end - start;
> if (t < 0) t = -t;
> - if (13 > r)
> - t = t << (13 - r);
> - else
> - t = t >> (r - 13);
> + t = t << (13 - r);
> return (t * 10) / (p * 441);
> }
>
> --
> 2.14.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] ALSA: synth: emux: remove redundant test for r <= 13
2017-11-17 11:06 ` Takashi Iwai
@ 2017-11-17 11:07 ` Colin Ian King
2017-11-17 11:11 ` walter harms
0 siblings, 1 reply; 4+ messages in thread
From: Colin Ian King @ 2017-11-17 11:07 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel, Jaroslav Kysela, kernel-janitors, linux-kernel
On 17/11/17 11:06, Takashi Iwai wrote:
> On Tue, 14 Nov 2017 18:26:53 +0100,
> Colin King wrote:
>>
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The calculation r = (3 - ((rate >> 6) & 3)) * 3 results in r being
>> 0, 3, 6 or 9 and so the check (13 > r) is always true and hence we
>> can remove the redundant check and the else path.
>>
>> Detected by CoverityScan, CID#744415 ("Logically dead code")
>>
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> The calculation of t itself can be generic in case we may add a
> support greater than the current r, so I don't think it's so much
> beneficial with this code reduction. Better to keep the code as
> reference.
OK, that's a good decision.
Colin
>
>
> thanks,
>
> Takashi
>
>> ---
>> sound/synth/emux/soundfont.c | 5 +----
>> 1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c
>> index 31a4ea94830e..0beb5a737c8b 100644
>> --- a/sound/synth/emux/soundfont.c
>> +++ b/sound/synth/emux/soundfont.c
>> @@ -858,10 +858,7 @@ calc_gus_envelope_time(int rate, int start, int end)
>> p = rate & 0x3f;
>> t = end - start;
>> if (t < 0) t = -t;
>> - if (13 > r)
>> - t = t << (13 - r);
>> - else
>> - t = t >> (r - 13);
>> + t = t << (13 - r);
>> return (t * 10) / (p * 441);
>> }
>>
>> --
>> 2.14.1
>>
>>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] ALSA: synth: emux: remove redundant test for r <= 13
2017-11-17 11:07 ` Colin Ian King
@ 2017-11-17 11:11 ` walter harms
0 siblings, 0 replies; 4+ messages in thread
From: walter harms @ 2017-11-17 11:11 UTC (permalink / raw)
To: Colin Ian King
Cc: Takashi Iwai, alsa-devel, Jaroslav Kysela, kernel-janitors,
linux-kernel
Am 17.11.2017 12:07, schrieb Colin Ian King:
> On 17/11/17 11:06, Takashi Iwai wrote:
>> On Tue, 14 Nov 2017 18:26:53 +0100,
>> Colin King wrote:
>>>
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> The calculation r = (3 - ((rate >> 6) & 3)) * 3 results in r being
>>> 0, 3, 6 or 9 and so the check (13 > r) is always true and hence we
>>> can remove the redundant check and the else path.
>>>
>>> Detected by CoverityScan, CID#744415 ("Logically dead code")
>>>
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>
>> The calculation of t itself can be generic in case we may add a
>> support greater than the current r, so I don't think it's so much
>> beneficial with this code reduction. Better to keep the code as
>> reference.
>
> OK, that's a good decision.
>
NTL is should be documented that this is intentional before the next
scanner finds it.
just my 2 cents,
re,
wh
> Colin
>>
>>
>> thanks,
>>
>> Takashi
>>
>>> ---
>>> sound/synth/emux/soundfont.c | 5 +----
>>> 1 file changed, 1 insertion(+), 4 deletions(-)
>>>
>>> diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c
>>> index 31a4ea94830e..0beb5a737c8b 100644
>>> --- a/sound/synth/emux/soundfont.c
>>> +++ b/sound/synth/emux/soundfont.c
>>> @@ -858,10 +858,7 @@ calc_gus_envelope_time(int rate, int start, int end)
>>> p = rate & 0x3f;
>>> t = end - start;
>>> if (t < 0) t = -t;
>>> - if (13 > r)
>>> - t = t << (13 - r);
>>> - else
>>> - t = t >> (r - 13);
>>> + t = t << (13 - r);
>>> return (t * 10) / (p * 441);
>>> }
>>>
>>> --
>>> 2.14.1
>>>
>>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-17 11:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-14 17:26 [PATCH] ALSA: synth: emux: remove redundant test for r <= 13 Colin King
2017-11-17 11:06 ` Takashi Iwai
2017-11-17 11:07 ` Colin Ian King
2017-11-17 11:11 ` walter harms
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox