Re: [PATCH 05/21] Make parse_tag_buffer_internal() handle item == NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Sat, 9 Jun 2007, Johan Herland wrote:

> -	tag_len = tagger_line - tag_line - strlen("tag \n");
> -	item->tag = xmalloc(tag_len + 1);
> -	memcpy(item->tag, tag_line + 4, tag_len);
> -	item->tag[tag_len] = '\0';
> -
> -	if (!strcmp(type, blob_type)) {
> -		item->tagged = &lookup_blob(sha1)->object;
> -	} else if (!strcmp(type, tree_type)) {
> -		item->tagged = &lookup_tree(sha1)->object;
> -	} else if (!strcmp(type, commit_type)) {
> -		item->tagged = &lookup_commit(sha1)->object;
> -	} else if (!strcmp(type, tag_type)) {
> -		item->tagged = &lookup_tag(sha1)->object;
> -	} else {
> -		error("Unknown type %s", type);
> -		item->tagged = NULL;
> -	}
> -
> -	if (item->tagged && track_object_refs) {
> -		struct object_refs *refs = alloc_object_refs(1);
> -		refs->ref[0] = item->tagged;
> -		set_object_refs(&item->object, refs);
> +	if (item) {
> +		tag_len = tagger_line - tag_line - strlen("tag \n");
> +		item->tag = xmalloc(tag_len + 1);
> +		memcpy(item->tag, tag_line + 4, tag_len);
> +		item->tag[tag_len] = '\0';
> +
> +		if (!strcmp(type, blob_type)) {
> +			item->tagged = &lookup_blob(sha1)->object;
> +		} else if (!strcmp(type, tree_type)) {
> +			item->tagged = &lookup_tree(sha1)->object;
> +		} else if (!strcmp(type, commit_type)) {
> +			item->tagged = &lookup_commit(sha1)->object;
> +		} else if (!strcmp(type, tag_type)) {
> +			item->tagged = &lookup_tag(sha1)->object;
> +		} else {
> +			error("Unknown type %s", type);
> +			item->tagged = NULL;
> +		}
> +
> +		if (item->tagged && track_object_refs) {
> +			struct object_refs *refs = alloc_object_refs(1);
> +			refs->ref[0] = item->tagged;
> +			set_object_refs(&item->object, refs);
> +		}
>  	}
>  
>  	return 0;

The patch would have been so much simpler, and so much more descriptive of 
what you're doing, had you just said

	if (!item)
		return 0;

Ciao,
Dscho

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux