On Wed, Sep 26, 2018 at 03:54:38PM -0400, Ben Peart wrote:
> +
> +#define EOIE_SIZE (4 + GIT_SHA1_RAWSZ) /* <4-byte offset> + <20-byte hash> */
> +#define EOIE_SIZE_WITH_HEADER (4 + 4 + EOIE_SIZE) /* <4-byte signature> + 
> <4-byte length> + EOIE_SIZE */

If you make these variables instead of macros, you can use
the_hash_algo, which makes this code sha256-friendlier and probably
can explain less, e.g. ...

> +
> +static size_t read_eoie_extension(const char *mmap, size_t mmap_size)
> +{
> +     /*
> +      * The end of index entries (EOIE) extension is guaranteed to be last
> +      * so that it can be found by scanning backwards from the EOF.
> +      *
> +      * "EOIE"
> +      * <4-byte length>
> +      * <4-byte offset>
> +      * <20-byte hash>
> +      */

        uint32_t EOIE_SIZE = 4 + the_hash_algo->rawsz;
        uint32_t EOIE_SIZE_WITH_HEADER = 4 + 4 + EOIE_SIZE;

> +     const char *index, *eoie;
> +     uint32_t extsize;
> +     size_t offset, src_offset;
> +     unsigned char hash[GIT_MAX_RAWSZ];
> +     git_hash_ctx c;
--
Duy

Reply via email to