Re: [PATCH 2/3] diff: omit found pointer from emit_callback

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

 



Stefan Beller <sbeller@xxxxxxxxxx> writes:

> diff --git a/diff.c b/diff.c
> index 4a6501c..79ad91d 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -354,7 +354,6 @@ struct emit_callback {
>  	const char **label_path;
>  	struct diff_words_data *diff_words;
>  	struct diff_options *opt;
> -	int *found_changesp;
>  	struct strbuf *header;
>  };

I briefly wondered if we have some callsites that do not want
o->found_changes to be modified (hence pointing this field at
elsewhere), but the fact that you can _remove_ this field means that
there is no such use case, which is good.

> @@ -722,7 +721,6 @@ static void emit_rewrite_diff(const char *name_a,
>  
>  	memset(&ecbdata, 0, sizeof(ecbdata));
>  	ecbdata.color_diff = want_color(o->use_color);
> -	ecbdata.found_changesp = &o->found_changes;
>  	ecbdata.ws_rule = whitespace_rule(name_b);
>  	ecbdata.opt = o;
>  	if (ecbdata.ws_rule & WS_BLANK_AT_EOF) {
> @@ -1215,13 +1213,13 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
>  	const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
>  	struct diff_options *o = ecbdata->opt;
>  	const char *line_prefix = diff_line_prefix(o);
> +	o->found_changes = 1;
>  
>  	if (ecbdata->header) {
>  		fprintf(o->file, "%s", ecbdata->header->buf);
>  		strbuf_reset(ecbdata->header);
>  		ecbdata->header = NULL;
>  	}
> -	*(ecbdata->found_changesp) = 1;

Is there a good reason to move the assignment up?  "The fact that
this function was called even once means we found some change" is
probably a good argument, but then I'd prefer to have a blank before
it to separate it (the first statement) from the block of decls.

No need to resend.  Thanks.



[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]