Re: [PATCH 1/2] xdiff-interface: allow consume function to quit early by returning non-zero

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

 



Nguyễn Thái Ngọc Duy  <pclouds@xxxxxxxxx> writes:

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
> ---

What is this for? No explanation?

> diff --git a/xdiff-interface.c b/xdiff-interface.c
> index 0e2c169..c5684b4 100644
> --- a/xdiff-interface.c
> +++ b/xdiff-interface.c
> @@ -56,7 +56,7 @@ int parse_hunk_header(char *line, int len,
>  	return -!!memcmp(cp, " @@", 3);
>  }
>  
> -static void consume_one(void *priv_, char *s, unsigned long size)
> +static int consume_one(void *priv_, char *s, unsigned long size)
>  {
>  	struct xdiff_emit_state *priv = priv_;
>  	char *ep;
> @@ -64,10 +64,12 @@ static void consume_one(void *priv_, char *s, unsigned long size)
>  		unsigned long this_size;
>  		ep = memchr(s, '\n', size);
>  		this_size = (ep == NULL) ? size : (ep - s + 1);
> -		priv->consume(priv->consume_callback_data, s, this_size);
> +		if (priv->consume(priv->consume_callback_data, s, this_size))
> +			return -1;
>  		size -= this_size;
>  		s += this_size;
>  	}
> +	return 0;
>  }

Returning a negative value implies that this is an error condition. Should
all "non-zero" returns from ->consume necessarily be considered error?

The same comment applies to the new "return -1" in the rest of the patch.
--
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]