Merge branch 'sl/const'

Code cleanup.

* sl/const:
  various: tighten constness of some local variables
This commit is contained in:
Junio C Hamano 2019-02-06 22:05:27 -08:00
commit 3a14fdec88
4 changed files with 15 additions and 15 deletions

View File

@ -103,7 +103,7 @@ static int builtin_diff_blobs(struct rev_info *revs,
int argc, const char **argv, int argc, const char **argv,
struct object_array_entry **blob) struct object_array_entry **blob)
{ {
unsigned mode = canon_mode(S_IFREG | 0644); const unsigned mode = canon_mode(S_IFREG | 0644);
if (argc > 1) if (argc > 1)
usage(builtin_diff_usage); usage(builtin_diff_usage);

View File

@ -1902,10 +1902,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 *a = *(struct object_entry **)_a;
const struct object_entry *b = *(struct object_entry **)_b; const struct object_entry *b = *(struct object_entry **)_b;
enum object_type a_type = oe_type(a); const enum object_type a_type = oe_type(a);
enum object_type b_type = oe_type(b); const enum object_type b_type = oe_type(b);
unsigned long a_size = SIZE(a); const unsigned long a_size = SIZE(a);
unsigned long b_size = SIZE(b); const unsigned long b_size = SIZE(b);
if (a_type > b_type) if (a_type > b_type)
return -1; return -1;
@ -1920,7 +1920,7 @@ static int type_size_sort(const void *_a, const void *_b)
if (a->preferred_base < b->preferred_base) if (a->preferred_base < b->preferred_base)
return 1; return 1;
if (use_delta_islands) { 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) if (island_cmp)
return island_cmp; return island_cmp;
} }
@ -2167,7 +2167,7 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)
struct object_entry *child = DELTA_CHILD(me); struct object_entry *child = DELTA_CHILD(me);
unsigned int m = n; unsigned int m = n;
while (child) { while (child) {
unsigned int c = check_delta_limit(child, n + 1); const unsigned int c = check_delta_limit(child, n + 1);
if (m < c) if (m < c)
m = c; m = c;
child = DELTA_SIBLING(child); child = DELTA_SIBLING(child);
@ -2222,7 +2222,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
while (window_memory_limit && while (window_memory_limit &&
mem_usage > window_memory_limit && mem_usage > window_memory_limit &&
count > 1) { count > 1) {
uint32_t tail = (idx + window - count) % window; const uint32_t tail = (idx + window - count) % window;
mem_usage -= free_unpacked(array + tail); mem_usage -= free_unpacked(array + tail);
count--; count--;
} }

View File

@ -166,7 +166,7 @@ redo_from_start:
l = (hint == NULL) ? list->front : hint; l = (hint == NULL) ? list->front : hint;
prev = NULL; prev = NULL;
while (l) { while (l) {
int cmp = oidcmp(l->oid, oid); const int cmp = oidcmp(l->oid, oid);
if (cmp > 0) /* not in list, since sorted */ if (cmp > 0) /* not in list, since sorted */
return prev; return prev;
if (!cmp) { /* found */ 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 && while (p1_off < p1->pack->num_objects * p1_step &&
p2_off < p2->pack->num_objects * p2_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 */ /* cmp ~ p1 - p2 */
if (cmp == 0) { if (cmp == 0) {
p1_hint = llist_sorted_remove(p1->unique_objects, p1_hint = llist_sorted_remove(p1->unique_objects,

View File

@ -119,7 +119,7 @@ static void sort_revindex(struct revindex_entry *entries, unsigned n, off_t max)
*/ */
static void create_pack_revindex(struct packed_git *p) static void create_pack_revindex(struct packed_git *p)
{ {
unsigned num_ent = p->num_objects; const unsigned num_ent = p->num_objects;
unsigned i; unsigned i;
const char *index = p->index_data; const char *index = p->index_data;
const unsigned hashsz = the_hash_algo->rawsz; const unsigned hashsz = the_hash_algo->rawsz;
@ -132,7 +132,7 @@ static void create_pack_revindex(struct packed_git *p)
(uint32_t *)(index + 8 + p->num_objects * (hashsz + 4)); (uint32_t *)(index + 8 + p->num_objects * (hashsz + 4));
const uint32_t *off_64 = off_32 + p->num_objects; const uint32_t *off_64 = off_32 + p->num_objects;
for (i = 0; i < num_ent; i++) { for (i = 0; i < num_ent; i++) {
uint32_t off = ntohl(*off_32++); const uint32_t off = ntohl(*off_32++);
if (!(off & 0x80000000)) { if (!(off & 0x80000000)) {
p->revindex[i].offset = off; p->revindex[i].offset = off;
} else { } else {
@ -143,7 +143,7 @@ static void create_pack_revindex(struct packed_git *p)
} }
} else { } else {
for (i = 0; i < num_ent; i++) { for (i = 0; i < num_ent; i++) {
uint32_t hl = *((uint32_t *)(index + (hashsz + 4) * i)); const uint32_t hl = *((uint32_t *)(index + (hashsz + 4) * i));
p->revindex[i].offset = ntohl(hl); p->revindex[i].offset = ntohl(hl);
p->revindex[i].nr = i; p->revindex[i].nr = i;
} }
@ -168,10 +168,10 @@ int find_revindex_position(struct packed_git *p, off_t ofs)
{ {
int lo = 0; int lo = 0;
int hi = p->num_objects + 1; int hi = p->num_objects + 1;
struct revindex_entry *revindex = p->revindex; const struct revindex_entry *revindex = p->revindex;
do { do {
unsigned mi = lo + (hi - lo) / 2; const unsigned mi = lo + (hi - lo) / 2;
if (revindex[mi].offset == ofs) { if (revindex[mi].offset == ofs) {
return mi; return mi;
} else if (ofs < revindex[mi].offset) } else if (ofs < revindex[mi].offset)