Skip to content

Commit

Permalink
use labs() for variables of type long instead of abs()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Nov 17, 2014
1 parent 7fa1365 commit 83915ba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 83915ba

Please sign in to comment.