commit eef1d245249331bf08381aadd8efc5cff7403c68 from: Omar Polo via: Thomas Adam date: Fri Jul 12 06:00:18 2024 UTC s/pack_sha1_ctx/pack_hash_ctx it's a bit silly to call the context for got_hash with sha1 since it's an API explicitly thought to abstract over the hash algorithm. Also, this is going to cover sha256 pack files soon too. commit - a5aca095b9115be7ad89415bcf0117e38202dfb8 commit + eef1d245249331bf08381aadd8efc5cff7403c68 blob - 5664cfa55cbbbebf65e037617cfa3913feda7ec8 blob + 2be3bfe0f7cfa024c74253a7aab5f4108edf1eb2 --- lib/pack_index.c +++ lib/pack_index.c @@ -144,7 +144,7 @@ read_file_digest(struct got_hash *ctx, FILE *f, size_t static const struct got_error * read_packed_object(struct got_pack *pack, struct got_indexed_object *obj, - FILE *tmpfile, struct got_hash *pack_sha1_ctx) + FILE *tmpfile, struct got_hash *pack_hash_ctx) { const struct got_error *err = NULL; struct got_hash ctx; @@ -158,7 +158,7 @@ read_packed_object(struct got_pack *pack, struct got_i struct got_inflate_checksum csum; memset(&csum, 0, sizeof(csum)); - csum.input_ctx = pack_sha1_ctx; + csum.input_ctx = pack_hash_ctx; csum.input_crc = &obj->crc; err = got_pack_parse_object_type_and_size(&obj->type, &obj->size, @@ -168,13 +168,13 @@ read_packed_object(struct got_pack *pack, struct got_i if (pack->map) { obj->crc = crc32(obj->crc, pack->map + mapoff, obj->tslen); - got_hash_update(pack_sha1_ctx, pack->map + mapoff, obj->tslen); + got_hash_update(pack_hash_ctx, pack->map + mapoff, obj->tslen); mapoff += obj->tslen; } else { /* XXX Seek back and get the CRC of on-disk type+size bytes. */ if (lseek(pack->fd, obj->off, SEEK_SET) == -1) return got_error_from_errno("lseek"); - err = read_checksum(&obj->crc, pack_sha1_ctx, + err = read_checksum(&obj->crc, pack_hash_ctx, pack->fd, obj->tslen); if (err) return err; @@ -248,7 +248,7 @@ read_packed_object(struct got_pack *pack, struct got_i SHA1_DIGEST_LENGTH); obj->crc = crc32(obj->crc, pack->map + mapoff, SHA1_DIGEST_LENGTH); - got_hash_update(pack_sha1_ctx, pack->map + mapoff, + got_hash_update(pack_hash_ctx, pack->map + mapoff, SHA1_DIGEST_LENGTH); mapoff += SHA1_DIGEST_LENGTH; err = got_inflate_to_mem_mmap(NULL, &datalen, @@ -269,7 +269,7 @@ read_packed_object(struct got_pack *pack, struct got_i } obj->crc = crc32(obj->crc, obj->delta.ref.ref_id.sha1, SHA1_DIGEST_LENGTH); - got_hash_update(pack_sha1_ctx, + got_hash_update(pack_hash_ctx, obj->delta.ref.ref_id.sha1, SHA1_DIGEST_LENGTH); err = got_inflate_to_mem_fd(NULL, &datalen, &obj->len, &csum, obj->size, pack->fd); @@ -304,7 +304,7 @@ read_packed_object(struct got_pack *pack, struct got_i obj->crc = crc32(obj->crc, pack->map + mapoff, obj->delta.ofs.base_offsetlen); - got_hash_update(pack_sha1_ctx, pack->map + mapoff, + got_hash_update(pack_hash_ctx, pack->map + mapoff, obj->delta.ofs.base_offsetlen); mapoff += obj->delta.ofs.base_offsetlen; err = got_inflate_to_mem_mmap(NULL, &datalen, @@ -322,7 +322,7 @@ read_packed_object(struct got_pack *pack, struct got_i err = got_error_from_errno("lseek"); break; } - err = read_checksum(&obj->crc, pack_sha1_ctx, + err = read_checksum(&obj->crc, pack_hash_ctx, pack->fd, obj->delta.ofs.base_offsetlen); if (err) break;