Re: [PATCH v7 2/7] read-cache: clean up casting and byte decoding
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Oct 1, 2018, 15:10 UTC
- Message-ID
- <CACsJy8DRLPmrGD1podPJ12G3VitsK3dQnq+2sOjCiQj6N4ayTQ@mail.gmail.com>
- In-Reply-To
- <20181001134556.33232-3-peartben@gmail.com>
On Mon, Oct 1, 2018 at 3:46 PM Ben Peart <peartben@gmail.com> wrote:
Show 24 quoted lines
> > From: Ben Peart <benpeart@microsoft.com> > > This patch does a clean up pass to minimize the casting required to work > with the memory mapped index (mmap). > > It also makes the decoding of network byte order more consistent by using > get_be32() where possible. > > Signed-off-by: Ben Peart <peartben@gmail.com> > --- > read-cache.c | 23 +++++++++++------------ > 1 file changed, 11 insertions(+), 12 deletions(-) > > diff --git a/read-cache.c b/read-cache.c > index 583a4fb1f8..6ba99e2c96 100644 > --- a/read-cache.c > +++ b/read-cache.c > @@ -1650,7 +1650,7 @@ int verify_index_checksum; > /* Allow fsck to force verification of the cache entry order. */ > int verify_ce_order; > > -static int verify_hdr(struct cache_header *hdr, unsigned long size) > +static int verify_hdr(const struct cache_header *hdr, unsigned long size)
OK more constness. Good.
Show 9 quoted lines
> {
> git_hash_ctx c;
> unsigned char hash[GIT_MAX_RAWSZ];
> @@ -1674,7 +1674,7 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
> }
>
> static int read_index_extension(struct index_state *istate,
> - const char *ext, void *data, unsigned long sz)
> + const char *ext, const char *data, unsigned long sz)But it's not clear why you need to change the data type from void * to char * here. I guess all the consumer functions take 'const char *' anyway, so it's best to use 'const char *'?
Not worth a reroll (to give a reason why you do this in the commit message), unless there are other changes.
-- Duy