[CRIU] [PATCH 10/23] vdso01 test: fix for clang

Kir Kolyshkin kir at openvz.org
Tue Oct 11 18:46:48 PDT 2016


clang complains:
> clang -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0  -iquote ../lib/arch/x86/include -I../lib   vdso01.c ../lib/libzdtmtst.a ../lib/libzdtmtst.a -lrt -o vdso01
> vdso01.c:305:6: error: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value
>       [-Werror,-Wabsolute-value]
>         if (abs(ts1.tv_sec - ts2.tv_sec) > TIME_DELTA_SEC) {
>             ^
> vdso01.c:305:6: note: use function 'labs' instead

Let's use labs() indeed.

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 test/zdtm/static/vdso01.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/zdtm/static/vdso01.c b/test/zdtm/static/vdso01.c
index 8db396e..fe52d19 100644
--- a/test/zdtm/static/vdso01.c
+++ b/test/zdtm/static/vdso01.c
@@ -302,7 +302,7 @@ static int vdso_clock_gettime_handler(void *func)
 	test_msg("clock_gettime: tv_sec %li vdso_clock_gettime: tv_sec %li\n",
 		 ts1.tv_sec, ts2.tv_sec);
 
-	if (abs(ts1.tv_sec - ts2.tv_sec) > TIME_DELTA_SEC) {
+	if (labs(ts1.tv_sec - ts2.tv_sec) > TIME_DELTA_SEC) {
 		pr_perror("Delta is too big");
 		return -1;
 	}
@@ -333,7 +333,7 @@ static int vdso_gettimeofday_handler(void *func)
 	test_msg("gettimeofday: tv_sec %li vdso_gettimeofday: tv_sec %li\n",
 		 tv1.tv_sec, tv2.tv_sec);
 
-	if (abs(tv1.tv_sec - tv2.tv_sec) > TIME_DELTA_SEC) {
+	if (labs(tv1.tv_sec - tv2.tv_sec) > TIME_DELTA_SEC) {
 		pr_perror("Delta is too big");
 		return -1;
 	}
@@ -351,7 +351,7 @@ static int vdso_time_handler(void *func)
 
 	test_msg("time: %li vdso_time: %li\n", (long)t1, (long)t1);
 
-	if (abs(t1 - t2) > TIME_DELTA_SEC) {
+	if (labs(t1 - t2) > TIME_DELTA_SEC) {
 		pr_perror("Delta is too big");
 		return -1;
 	}
-- 
2.7.4



More information about the CRIU mailing list