[LTP] [PATCH 1/1] swapping01: fix parameter truncation in abs

Petr Vorel pvorel@suse.cz
Wed Jan 20 12:11:27 CET 2021


Hi Alexander,

> Parameters passed to abs(int) are of type long. Use labs(long) instead
> to avoid value truncation.

> Fixes the following warning:

> swapping01.c: In function ‘check_swapping’:
> swapping01.c:133:7: warning: absolute value function ‘abs’ given an argument of type ‘long int’ but has parameter of type ‘int’ which may cause truncation of value [-Wabsolute-value]
>   133 |   if (abs(swap_free_now - SAFE_READ_MEMINFO("SwapFree:")) < 512)
>       |       ^~~

Merged this obvious fix. Thanks!

Kind regards,
Petr


More information about the ltp mailing list