summaryrefslogtreecommitdiff
path: root/shallow.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-07-08 12:35:35 +0200
committerJunio C Hamano <gitster@pobox.com>2017-07-10 14:24:36 -0700
commit42c78a216e751cfa2720c8276c9e9f2b81640e6b (patch)
treeff12c046af74e524d80ec247f8039592337afee6 /shallow.c
parent8c8e978f5719c6a58fb998742207bf907f963143 (diff)
downloadgit-42c78a216e751cfa2720c8276c9e9f2b81640e6b.tar.gz
use DIV_ROUND_UPrs/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 'shallow.c')
-rw-r--r--shallow.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/shallow.c b/shallow.c
index f9370961f9..1aee070c4d 100644
--- a/shallow.c
+++ b/shallow.c
@@ -443,7 +443,7 @@ struct paint_info {
static uint32_t *paint_alloc(struct paint_info *info)
{
- unsigned nr = (info->nr_bits + 31) / 32;
+ unsigned nr = DIV_ROUND_UP(info->nr_bits, 32);
unsigned size = nr * sizeof(uint32_t);
void *p;
if (!info->pool_count || size > info->end - info->free) {
@@ -471,7 +471,7 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1,
{
unsigned int i, nr;
struct commit_list *head = NULL;
- int bitmap_nr = (info->nr_bits + 31) / 32;
+ int bitmap_nr = DIV_ROUND_UP(info->nr_bits, 32);
size_t bitmap_size = st_mult(sizeof(uint32_t), bitmap_nr);
struct commit *c = lookup_commit_reference_gently(sha1, 1);
uint32_t *tmp; /* to be freed before return */
@@ -611,7 +611,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
paint_down(&pi, ref->oid[i].hash, i);
if (used) {
- int bitmap_size = ((pi.nr_bits + 31) / 32) * sizeof(uint32_t);
+ int bitmap_size = DIV_ROUND_UP(pi.nr_bits, 32) * sizeof(uint32_t);
memset(used, 0, sizeof(*used) * info->shallow->nr);
for (i = 0; i < nr_shallow; i++) {
const struct commit *c = lookup_commit(oid[shallow[i]].hash);
@@ -672,7 +672,7 @@ static void post_assign_shallow(struct shallow_info *info,
struct commit *c;
uint32_t **bitmap;
int dst, i, j;
- int bitmap_nr = (info->ref->nr + 31) / 32;
+ int bitmap_nr = DIV_ROUND_UP(info->ref->nr, 32);
struct commit_array ca;
trace_printf_key(&trace_shallow, "shallow: post_assign_shallow\n");