From: Junio C Hamano Date: Sat, 09 Jun 2007 18:01:53 GMT Subject: Re: [PATCH 05/21] Make parse_tag_buffer_internal() handle item == NULL Message-ID: <7vlketf1m6.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <200706090214.39337.johan@herland.net> Johan Herland writes: > This is in preparation for unifying verify_tag() and > parse_tag_buffer_internal(). > > Signed-off-by: Johan Herland > --- > tag.c | 54 +++++++++++++++++++++++++++++------------------------- > 1 files changed, 29 insertions(+), 25 deletions(-) > > diff --git a/tag.c b/tag.c > index 19c66cd..b134967 100644 > --- a/tag.c > +++ b/tag.c > @@ -46,9 +46,11 @@ static int parse_tag_buffer_internal(struct tag *item, const char *data, const u > const char *type_line, *tag_line, *tagger_line; > unsigned long type_len, tag_len; > > - if (item->object.parsed) > - return 0; > - item->object.parsed = 1; > + if (item) { > + if (item->object.parsed) > + return 0; > + item->object.parsed = 1; > + } > > if (size < 64) > return error("failed preliminary size check"); Passing both item and data does not feel right. If you are trying to make the factored out function to do the verification of data, then perhaps the caller should do the "don't handle the same data twice" optimization using item?