1
0
mirror of https://github.com/git/git.git synced 2024-09-22 07:50:46 +02:00

use labs() for variables of type long instead of abs()

Using abs() on long values can cause truncation, so use labs() instead.
Reported by Clang 3.5 (-Wabsolute-value, enabled by -Wall).

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe 2014-11-15 14:27:21 +01:00 committed by Junio C Hamano
parent 7fa1365c54
commit 83915ba521

View File

@ -490,9 +490,9 @@ static int git_parse_signed(const char *value, intmax_t *ret, intmax_t max)
errno = EINVAL;
return 0;
}
uval = abs(val);
uval = labs(val);
uval *= factor;
if (uval > max || abs(val) > uval) {
if (uval > max || labs(val) > uval) {
errno = ERANGE;
return 0;
}