summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar René Scharfe <l.s.r@web.de>2017-07-08 12:35:35 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-07-10 14:24:36 -0700
commit42c78a216e751cfa2720c8276c9e9f2b81640e6b (patch)
treeff12c046af74e524d80ec247f8039592337afee6 /builtin
parentGit 2.13.2 (diff)
downloadtgif-42c78a216e751cfa2720c8276c9e9f2b81640e6b.tar.xz
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 <l.s.r@web.de> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/gc.c2
-rw-r--r--builtin/grep.c2
-rw-r--r--builtin/log.c2
-rw-r--r--builtin/receive-pack.c2
4 files changed, 4 insertions, 4 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index 91f7696a85..0477c2451f 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -148,7 +148,7 @@ static int too_many_loose_objects(void)
if (!dir)
return 0;
- auto_threshold = (gc_auto_threshold + 255) / 256;
+ auto_threshold = DIV_ROUND_UP(gc_auto_threshold, 256);
while ((ent = readdir(dir)) != NULL) {
if (strspn(ent->d_name, "0123456789abcdef") != 38 ||
ent->d_name[38] != '\0')
diff --git a/builtin/grep.c b/builtin/grep.c
index 254c1c7849..dc001da562 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -524,7 +524,7 @@ static void compile_submodule_options(const struct grep_opt *opt,
* submodule process has its own thread pool.
*/
argv_array_pushf(&submodule_options, "--threads=%d",
- (num_threads + 1) / 2);
+ DIV_ROUND_UP(num_threads, 2));
/* Add Pathspecs */
argv_array_push(&submodule_options, "--");
diff --git a/builtin/log.c b/builtin/log.c
index 57ce470f50..96c050b450 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1302,7 +1302,7 @@ static struct commit *get_base_commit(const char *base_commit,
if (rev_nr % 2)
rev[i] = rev[2 * i];
- rev_nr = (rev_nr + 1) / 2;
+ rev_nr = DIV_ROUND_UP(rev_nr, 2);
}
if (!in_merge_bases(base, rev[0]))
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index da9a3a2c9d..90d58c2fed 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1805,7 +1805,7 @@ static const char *unpack_with_sideband(struct shallow_info *si)
static void prepare_shallow_update(struct command *commands,
struct shallow_info *si)
{
- int i, j, k, bitmap_size = (si->ref->nr + 31) / 32;
+ int i, j, k, bitmap_size = DIV_ROUND_UP(si->ref->nr, 32);
ALLOC_ARRAY(si->used_shallow, si->shallow->nr);
assign_shallow_commits_to_refs(si, si->used_shallow, NULL);