[PATCH xf86-video-mga] Use fabs() to compute absolute value of floating point number.

Alan Coopersmith alan.coopersmith at oracle.com
Mon Nov 26 20:28:00 UTC 2018


On 11/26/18 12:12 PM, Matthieu Herrb wrote:
> Fixes a warning from clang and looks like it was a real bug.
> 
> Signed-off-by: Matthieu Herrb <matthieu at herrb.eu>
> ---
>   src/mga_dacG.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mga_dacG.c b/src/mga_dacG.c
> index 3b0d93e..5c08f8a 100644
> --- a/src/mga_dacG.c
> +++ b/src/mga_dacG.c
> @@ -986,8 +986,8 @@ MGAGCalcClock ( ScrnInfoPtr pScrn, long f_out,
>   			/*
>   			 * Pick the closest frequency.
>   			 */
> -			if ( abs(calc_f - f_vco) < m_err ) {
> -				m_err = abs(calc_f - f_vco);
> +			if ( fabs(calc_f - f_vco) < m_err ) {
> +				m_err = fabs(calc_f - f_vco);
>   				*best_m = m;
>   				*best_n = n;
>   			}
> 

Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

(It might have worked as is back when it was written, before the abs()
  macro was deleted from the X server's misc.h:
https://cgit.freedesktop.org/xorg/xserver/commit/include/misc.h?id=d568221710959cf7d783e6ff0fb80fb43a231124 
)


-- 
	-Alan Coopersmith-               alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - https://blogs.oracle.com/alanc


More information about the xorg-devel mailing list