[vlc-devel] [PATCH] input: fix the rate sign check

Rémi Denis-Courmont remi at remlab.net
Thu Jun 6 14:37:59 CEST 2019


I don't think compilers have hard-coded knowledge of fabsf() that would be required to warn here. Compilers can't/don't optimize/analyze floating point as well as integer arithmetic.

Anyway, signbit () is both faster (just extracts a bit) and safer (handles special values) if you want the sign. If you want to check less than zero, then that's isless() & co. They're not the same thing since negative zero exists.

Le 5 juin 2019 14:54:53 GMT+03:00, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
>fabsf( param.val.f_float ) cannot be negative.
>
>Compilers should warn about this.
>---
> src/input/input.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/src/input/input.c b/src/input/input.c
>index a6116ab8e7..97ee9a6bb6 100644
>--- a/src/input/input.c
>+++ b/src/input/input.c
>@@ -1920,7 +1920,7 @@ static bool Control( input_thread_t *p_input,
>         {
>             /* Get rate and direction */
>             float rate = fabsf( param.val.f_float );
>-            int i_rate_sign = rate < 0 ? -1 : 1;
>+            int i_rate_sign = param.val.f_float < 0 ? -1 : 1;
> 
>             /* Check rate bound */
>             if( rate > INPUT_RATE_MAX )
>-- 
>2.17.1
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20190606/dfff9a2a/attachment.html>


More information about the vlc-devel mailing list