Commit Diff


commit - 05f7204b7c26d432547753965bf1a27fb7fb2e01
commit + 6934d8276a5597290aa75da9690021b694ce66e3
blob - b6b4541f9756fd1fc9eb3329cd32a375b2a4b874
blob + 251cdbaaf18885bef299a7edee1e4be43a305857
--- lib/got_lib_object_parse.h
+++ lib/got_lib_object_parse.h
@@ -31,7 +31,7 @@ struct got_parsed_tree_entry {
 	size_t namelen; /* strlen(name) */
 	mode_t mode; /* Mode parsed from tree buffer. */
 	uint8_t *id; /* Points to ID in parsed tree buffer. */
-	size_t idlen;
+	size_t digest_len;
 	int algo;
 };
 const struct got_error *got_object_parse_tree_entry(
blob - 0527d5d744aafecf3256df577f428320a5aa716d
blob + 6d3cc02388107ba9636418a37dd0a10e66670f94
--- lib/object_open_io.c
+++ lib/object_open_io.c
@@ -567,7 +567,7 @@ open_tree(struct got_tree_object **tree,
 			err = got_error(GOT_ERR_NO_SPACE);
 			goto done;
 		}
-		memcpy(te->id.hash, pe->id, pe->idlen);
+		memcpy(te->id.hash, pe->id, pe->digest_len);
 		te->id.algo = pe->algo;
 		te->mode = pe->mode;
 		te->idx = i;
blob - 13da36f4db4623f60a2b68897885e715fba89ba1
blob + 35db86beeeb7e5e79780d56b6c7304fd4eefe51f
--- lib/object_parse.c
+++ lib/object_parse.c
@@ -764,7 +764,7 @@ got_object_tree_close(struct got_tree_object *tree)
 
 const struct got_error *
 got_object_parse_tree_entry(struct got_parsed_tree_entry *pte, size_t *elen,
-    char *buf, size_t maxlen, size_t idlen, enum got_hash_algorithm algo)
+    char *buf, size_t maxlen, size_t digest_len, enum got_hash_algorithm algo)
 {
 	char *p, *space;
 
@@ -788,16 +788,16 @@ got_object_parse_tree_entry(struct got_parsed_tree_ent
 		p++;
 	}
 
-	if (*elen > maxlen || maxlen - *elen < idlen)
+	if (*elen > maxlen || maxlen - *elen < digest_len)
 		return got_error(GOT_ERR_BAD_OBJ_DATA);
 
 	pte->name = space + 1;
 	pte->namelen = strlen(pte->name);
 	buf += *elen;
 	pte->id = buf;
-	pte->idlen = idlen;
+	pte->digest_len = digest_len;
 	pte->algo = algo;
-	*elen += idlen;
+	*elen += digest_len;
 	return NULL;
 }
 
blob - 480a6f9d0e7a60f9920ec458ea66f95802e59079
blob + 8dc9adc210203ebedb74801ccf880e731d62df8b
--- lib/pack.c
+++ lib/pack.c
@@ -78,12 +78,12 @@ got_packidx_init_hdr(struct got_packidx *p, int verify
 	struct got_packidx_v2_hdr *h;
 	struct got_hash ctx;
 	uint8_t hash[GOT_HASH_DIGEST_MAXLEN];
-	size_t nobj, len_fanout, len_ids, offset, remain, idlen;
+	size_t nobj, len_fanout, len_ids, offset, remain, digest_string_len;
 	ssize_t n;
 	int i;
 
 	got_hash_init(&ctx, p->algo);
-	idlen = got_hash_digest_length(p->algo);
+	digest_string_len = got_hash_digest_length(p->algo);
 
 	h = &p->hdr;
 	offset = 0;
@@ -303,31 +303,34 @@ got_packidx_init_hdr(struct got_packidx *p, int verify
 	offset += p->nlargeobj * sizeof(*h->large_offsets);
 
 checksum:
-	if (remain < idlen * 2) {
+	if (remain < digest_string_len * 2) {
 		err = got_error(GOT_ERR_BAD_PACKIDX);
 		goto done;
 	}
 	if (p->map) {
-		memcpy(h->trailer.packfile_hash, p->map + offset, idlen);
-		memcpy(h->trailer.packidx_hash, p->map + offset + idlen, idlen);
+		memcpy(h->trailer.packfile_hash, p->map + offset,
+		    digest_string_len);
+		memcpy(h->trailer.packidx_hash,
+		    p->map + offset + digest_string_len, digest_string_len);
 	} else {
-		n = read(p->fd, h->trailer.packfile_hash, idlen);
+		n = read(p->fd, h->trailer.packfile_hash, digest_string_len);
 		if (n < 0)
 			err = got_error_from_errno("read");
-		else if (n != idlen) {
+		else if (n != digest_string_len) {
 			err = got_error(GOT_ERR_BAD_PACKIDX);
 			goto done;
 		}
-		n = read(p->fd, h->trailer.packidx_hash, idlen);
+		n = read(p->fd, h->trailer.packidx_hash, digest_string_len);
 		if (n < 0)
 			err = got_error_from_errno("read");
-		else if (n != idlen) {
+		else if (n != digest_string_len) {
 			err = got_error(GOT_ERR_BAD_PACKIDX);
 			goto done;
 		}
 	}
 	if (verify) {
-		got_hash_update(&ctx, h->trailer.packfile_hash, idlen);
+		got_hash_update(&ctx, h->trailer.packfile_hash,
+		    digest_string_len);
 		got_hash_final(&ctx, hash);
 		if (got_hash_cmp(ctx.algo, hash, h->trailer.packidx_hash) != 0)
 			err = got_error(GOT_ERR_PACKIDX_CSUM);
blob - 42906a3ad5dc8e31e2858ff79937b7a91ecb6ddb
blob + 116131bdf6703cf5fe030ee142ac6ffed00267b4
--- lib/privsep.c
+++ lib/privsep.c
@@ -1456,7 +1456,7 @@ send_tree_entries_batch(struct imsgbuf *ibuf,
 		struct got_parsed_tree_entry *pte = &entries[i];
 
 		/* Keep in sync with struct got_imsg_tree_entry definition! */
-		if (imsg_add(wbuf, pte->id, pte->idlen) == -1)
+		if (imsg_add(wbuf, pte->id, pte->digest_len) == -1)
 			return got_error_from_errno("imsg_add TREE_ENTRY");
 		if (pte->algo == GOT_HASH_SHA1 &&
 		    imsg_add(wbuf, gap, sizeof(gap)) == -1)
blob - 8310d258ed0862c91aa319a890177e42fbb539df
blob + f7bc857b9b977973277020c4b6df2828e8c6bd29
--- lib/reference.c
+++ lib/reference.c
@@ -298,10 +298,10 @@ parse_packed_ref_line(struct got_reference **ref, cons
 {
 	struct got_object_id id;
 	const char *name;
-	size_t idlen;
+	size_t digest_string_len;
 
 	*ref = NULL;
-	idlen = got_hash_digest_string_length(algo);
+	digest_string_len = got_hash_digest_string_length(algo);
 
 	if (line[0] == '#' || line[0] == '^')
 		return NULL;
@@ -310,11 +310,11 @@ parse_packed_ref_line(struct got_reference **ref, cons
 		return got_error(GOT_ERR_BAD_REF_DATA);
 
 	if (abs_refname) {
-		if (strcmp(line + idlen, abs_refname) != 0)
+		if (strcmp(line + digest_string_len, abs_refname) != 0)
 			return NULL;
 		name = abs_refname;
 	} else
-		name = line + idlen;
+		name = line + digest_string_len;
 
 	return alloc_ref(ref, name, &id, GOT_REF_IS_PACKED, mtime);
 }
blob - 4a2aa626c6bfeafe49ae89b98803e3ba71f9ba15
blob + 04437057664e089f746308bec4509bd46f5b790e
--- lib/repository.c
+++ lib/repository.c
@@ -1197,17 +1197,17 @@ int
 got_repo_is_packidx_filename(const char *name, size_t len,
     enum got_hash_algorithm algo)
 {
-	size_t idlen;
+	size_t digest_string_len;
 
-	idlen = got_hash_digest_string_length(algo);
+	digest_string_len = got_hash_digest_string_length(algo);
 
-	if (len != GOT_PACKIDX_NAMELEN(idlen))
+	if (len != GOT_PACKIDX_NAMELEN(digest_string_len))
 		return 0;
 
 	if (strncmp(name, GOT_PACK_PREFIX, strlen(GOT_PACK_PREFIX)) != 0)
 		return 0;
 
-	if (strcmp(name + strlen(GOT_PACK_PREFIX) + idlen - 1,
+	if (strcmp(name + strlen(GOT_PACK_PREFIX) + digest_string_len - 1,
 	    GOT_PACKIDX_SUFFIX) != 0)
 		return 0;
 
blob - 34cc8e56ce949b897f9175c59785d3bfed510de9
blob + 8e713d79d7f255089269071dded73b02cc503bab
--- libexec/got-read-pack/got-read-pack.c
+++ libexec/got-read-pack/got-read-pack.c
@@ -453,7 +453,7 @@ tree_path_changed(int *changed, uint8_t **buf1, size_t
 	const struct got_error *err = NULL;
 	struct got_parsed_tree_entry pte1, pte2;
 	const char *seg, *s;
-	size_t seglen, idlen;
+	size_t seglen, digest_len;
 	size_t remain1 = *len1, remain2 = *len2, elen;
 	uint8_t *next_entry1 = *buf1;
 	uint8_t *next_entry2 = *buf2;
@@ -463,7 +463,7 @@ tree_path_changed(int *changed, uint8_t **buf1, size_t
 
 	*changed = 0;
 
-	idlen = got_hash_digest_length(pack->algo);
+	digest_len = got_hash_digest_length(pack->algo);
 
 	/* We not do support comparing the root path. */
 	if (got_path_is_root_dir(path))
@@ -495,7 +495,7 @@ tree_path_changed(int *changed, uint8_t **buf1, size_t
 		 */
 		while (remain1 > 0) {
 			err = got_object_parse_tree_entry(&pte1, &elen,
-			    next_entry1, remain1, idlen, pack->algo);
+			    next_entry1, remain1, digest_len, pack->algo);
 			if (err)
 				return err;
 			next_entry1 += elen;
@@ -519,7 +519,7 @@ tree_path_changed(int *changed, uint8_t **buf1, size_t
 
 		while (remain2 > 0) {
 			err = got_object_parse_tree_entry(&pte2, &elen,
-			    next_entry2, remain2, idlen, pack->algo);
+			    next_entry2, remain2, digest_len, pack->algo);
 			if (err)
 				return err;
 			next_entry2 += elen;
@@ -542,7 +542,7 @@ tree_path_changed(int *changed, uint8_t **buf1, size_t
 			break;
 		}
 
-		if (memcmp(pte1.id, pte2.id, pte1.idlen) == 0) {
+		if (memcmp(pte1.id, pte2.id, pte1.digest_len) == 0) {
 			*changed = 0;
 			break;
 		}
@@ -559,7 +559,7 @@ tree_path_changed(int *changed, uint8_t **buf1, size_t
 			struct got_object_id id1, id2;
 			int idx;
 
-			memcpy(id1.hash, pte1.id, pte1.idlen);
+			memcpy(id1.hash, pte1.id, pte1.digest_len);
 			id1.algo = pack->algo;
 			idx = got_packidx_get_object_idx(packidx, &id1);
 			if (idx == -1) {
@@ -576,7 +576,7 @@ tree_path_changed(int *changed, uint8_t **buf1, size_t
 			next_entry1 = *buf1;
 			remain1 = *len1;
 
-			memcpy(id2.hash, pte2.id, pte2.idlen);
+			memcpy(id2.hash, pte2.id, pte2.digest_len);
 			id2.algo = pack->algo;
 			idx = got_packidx_get_object_idx(packidx, &id2);
 			if (idx == -1) {
@@ -1279,7 +1279,7 @@ enumerate_tree(int *have_all_entries, struct imsgbuf *
 			if (err)
 				goto done;
 			eqid->id.algo = pte->algo;
-			memcpy(eqid->id.hash, pte->id, pte->idlen);
+			memcpy(eqid->id.hash, pte->id, pte->digest_len);
 
 			if (got_object_idset_contains(idset, &eqid->id)) {
 				got_object_qid_free(eqid);