Re: [PATCH] selftests/resctrl: fix clang build warnings related to abs(), labs() calls

From: John Hubbard
Date: Fri May 10 2024 - 14:01:45 EST


On 5/10/24 2:06 AM, Ilpo Järvinen wrote:
On Wed, 8 May 2024, John Hubbard wrote:

When building with clang, via:

make LLVM=1 -C tools/testing/selftests

...two types of warnings occur:

warning: absolute value function 'abs' given an argument of type
'long' but has parameter of type 'int' which may cause truncation of
value

warning: taking the absolute value of unsigned type 'unsigned long'
has no effect

Fix these by:

a) using labs() in place of abs(), when long integers are involved, and

b) Change to use signed integer data types, in places where subtraction
is used (and could end up with negative values).

c) Remove a duplicate abs() call in cmt_test.c.

In general, instead of filename, it's better to refer to the actual
function in this kind of description. And in this particular case,
cmt_test.c could be replaced with "the CMT selftest" which is more
descriptive and still unambiguous.

Sure, I'll change that.


Cc: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Cc: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>

Thank you.

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>


Thanks for the review!


thanks,
--
John Hubbard
NVIDIA