From 33de80b1d50773f79e380eff33b4fc5c8ae1dd25 Mon Sep 17 00:00:00 2001 From: Shahzad Lone Date: Sat, 2 Feb 2019 23:16:45 +0000 Subject: various: tighten constness of some local variables Signed-off-by: Shahzad Lone Signed-off-by: Junio C Hamano --- builtin/diff.c | 2 +- builtin/pack-objects.c | 14 +++++++------- builtin/pack-redundant.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'builtin') diff --git a/builtin/diff.c b/builtin/diff.c index f0393bba23..84a362ff56 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -102,7 +102,7 @@ static int builtin_diff_blobs(struct rev_info *revs, int argc, const char **argv, struct object_array_entry **blob) { - unsigned mode = canon_mode(S_IFREG | 0644); + const unsigned mode = canon_mode(S_IFREG | 0644); if (argc > 1) usage(builtin_diff_usage); diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 0a70d04604..5c406ab494 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1901,10 +1901,10 @@ static int type_size_sort(const void *_a, const void *_b) { const struct object_entry *a = *(struct object_entry **)_a; const struct object_entry *b = *(struct object_entry **)_b; - enum object_type a_type = oe_type(a); - enum object_type b_type = oe_type(b); - unsigned long a_size = SIZE(a); - unsigned long b_size = SIZE(b); + const enum object_type a_type = oe_type(a); + const enum object_type b_type = oe_type(b); + const unsigned long a_size = SIZE(a); + const unsigned long b_size = SIZE(b); if (a_type > b_type) return -1; @@ -1919,7 +1919,7 @@ static int type_size_sort(const void *_a, const void *_b) if (a->preferred_base < b->preferred_base) return 1; if (use_delta_islands) { - int island_cmp = island_delta_cmp(&a->idx.oid, &b->idx.oid); + const int island_cmp = island_delta_cmp(&a->idx.oid, &b->idx.oid); if (island_cmp) return island_cmp; } @@ -2171,7 +2171,7 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n) struct object_entry *child = DELTA_CHILD(me); unsigned int m = n; while (child) { - unsigned int c = check_delta_limit(child, n + 1); + const unsigned int c = check_delta_limit(child, n + 1); if (m < c) m = c; child = DELTA_SIBLING(child); @@ -2226,7 +2226,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size, while (window_memory_limit && mem_usage > window_memory_limit && count > 1) { - uint32_t tail = (idx + window - count) % window; + const uint32_t tail = (idx + window - count) % window; mem_usage -= free_unpacked(array + tail); count--; } diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c index cf9a9aabd4..11bc514566 100644 --- a/builtin/pack-redundant.c +++ b/builtin/pack-redundant.c @@ -166,7 +166,7 @@ redo_from_start: l = (hint == NULL) ? list->front : hint; prev = NULL; while (l) { - int cmp = oidcmp(l->oid, oid); + const int cmp = oidcmp(l->oid, oid); if (cmp > 0) /* not in list, since sorted */ return prev; if (!cmp) { /* found */ @@ -264,7 +264,7 @@ static void cmp_two_packs(struct pack_list *p1, struct pack_list *p2) while (p1_off < p1->pack->num_objects * p1_step && p2_off < p2->pack->num_objects * p2_step) { - int cmp = hashcmp(p1_base + p1_off, p2_base + p2_off); + const int cmp = hashcmp(p1_base + p1_off, p2_base + p2_off); /* cmp ~ p1 - p2 */ if (cmp == 0) { p1_hint = llist_sorted_remove(p1->unique_objects, -- cgit v1.2.3