From 42c78a216e751cfa2720c8276c9e9f2b81640e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 8 Jul 2017 12:35:35 +0200 Subject: use DIV_ROUND_UP Convert code that divides and rounds up to use DIV_ROUND_UP to make the intent clearer and reduce the number of magic constants. Signed-off-by: Rene Scharfe Reviewed-by: Jeff King Signed-off-by: Junio C Hamano --- sha1_name.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sha1_name.c') diff --git a/sha1_name.c b/sha1_name.c index 5e2ec37b6..f7b624291 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -479,10 +479,9 @@ int find_unique_abbrev_r(char *hex, const unsigned char *sha1, int len) * We now know we have on the order of 2^len objects, which * expects a collision at 2^(len/2). But we also care about hex * chars, not bits, and there are 4 bits per hex. So all - * together we need to divide by 2; but we also want to round - * odd numbers up, hence adding one before dividing. + * together we need to divide by 2 and round up. */ - len = (len + 1) / 2; + len = DIV_ROUND_UP(len, 2); /* * For very small repos, we stick with our regular fallback. */ -- cgit v1.2.1