зеркало из https://github.com/microsoft/git.git
remove ecb parameter from xdi_diff_outf()
xdi_diff_outf() overrides the structure members of its last parameter, ignoring any value that callers pass in. It's no surprise then that all callers pass a pointer to an uninitialized structure. They also don't read it after the call, so the parameter is neither used for input nor for output. Turn it into a local variable of xdi_diff_outf(). Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
ed215b109f
Коммит
dfea79004c
|
@ -211,7 +211,6 @@ static void combine_diff(const unsigned char *parent, unsigned int mode,
|
|||
xpparam_t xpp;
|
||||
xdemitconf_t xecfg;
|
||||
mmfile_t parent_file;
|
||||
xdemitcb_t ecb;
|
||||
struct combine_diff_state state;
|
||||
unsigned long sz;
|
||||
|
||||
|
@ -231,7 +230,7 @@ static void combine_diff(const unsigned char *parent, unsigned int mode,
|
|||
state.n = n;
|
||||
|
||||
xdi_diff_outf(&parent_file, result_file, consume_line, &state,
|
||||
&xpp, &xecfg, &ecb);
|
||||
&xpp, &xecfg);
|
||||
free(parent_file.ptr);
|
||||
|
||||
/* Assign line numbers for this parent.
|
||||
|
|
15
diff.c
15
diff.c
|
@ -696,7 +696,6 @@ static void diff_words_show(struct diff_words_data *diff_words)
|
|||
{
|
||||
xpparam_t xpp;
|
||||
xdemitconf_t xecfg;
|
||||
xdemitcb_t ecb;
|
||||
mmfile_t minus, plus;
|
||||
|
||||
/* special case: only removal */
|
||||
|
@ -718,7 +717,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
|
|||
/* as only the hunk header will be parsed, we need a 0-context */
|
||||
xecfg.ctxlen = 0;
|
||||
xdi_diff_outf(&minus, &plus, fn_out_diff_words_aux, diff_words,
|
||||
&xpp, &xecfg, &ecb);
|
||||
&xpp, &xecfg);
|
||||
free(minus.ptr);
|
||||
free(plus.ptr);
|
||||
if (diff_words->current_plus != diff_words->plus.text.ptr +
|
||||
|
@ -1704,7 +1703,6 @@ static void builtin_diff(const char *name_a,
|
|||
const char *diffopts = getenv("GIT_DIFF_OPTS");
|
||||
xpparam_t xpp;
|
||||
xdemitconf_t xecfg;
|
||||
xdemitcb_t ecb;
|
||||
struct emit_callback ecbdata;
|
||||
const struct userdiff_funcname *pe;
|
||||
|
||||
|
@ -1776,7 +1774,7 @@ static void builtin_diff(const char *name_a,
|
|||
}
|
||||
}
|
||||
xdi_diff_outf(&mf1, &mf2, fn_out_consume, &ecbdata,
|
||||
&xpp, &xecfg, &ecb);
|
||||
&xpp, &xecfg);
|
||||
if (DIFF_OPT_TST(o, COLOR_DIFF_WORDS))
|
||||
free_diff_words_data(&ecbdata);
|
||||
if (textconv_one)
|
||||
|
@ -1829,13 +1827,12 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
|
|||
/* Crazy xdl interfaces.. */
|
||||
xpparam_t xpp;
|
||||
xdemitconf_t xecfg;
|
||||
xdemitcb_t ecb;
|
||||
|
||||
memset(&xpp, 0, sizeof(xpp));
|
||||
memset(&xecfg, 0, sizeof(xecfg));
|
||||
xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
|
||||
xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
|
||||
&xpp, &xecfg, &ecb);
|
||||
&xpp, &xecfg);
|
||||
}
|
||||
|
||||
free_and_return:
|
||||
|
@ -1877,14 +1874,13 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
|
|||
/* Crazy xdl interfaces.. */
|
||||
xpparam_t xpp;
|
||||
xdemitconf_t xecfg;
|
||||
xdemitcb_t ecb;
|
||||
|
||||
memset(&xpp, 0, sizeof(xpp));
|
||||
memset(&xecfg, 0, sizeof(xecfg));
|
||||
xecfg.ctxlen = 1; /* at least one context line */
|
||||
xpp.flags = XDF_NEED_MINIMAL;
|
||||
xdi_diff_outf(&mf1, &mf2, checkdiff_consume, &data,
|
||||
&xpp, &xecfg, &ecb);
|
||||
&xpp, &xecfg);
|
||||
|
||||
if (data.ws_rule & WS_BLANK_AT_EOF) {
|
||||
struct emit_callback ecbdata;
|
||||
|
@ -3361,7 +3357,6 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
|
|||
for (i = 0; i < q->nr; i++) {
|
||||
xpparam_t xpp;
|
||||
xdemitconf_t xecfg;
|
||||
xdemitcb_t ecb;
|
||||
mmfile_t mf1, mf2;
|
||||
struct diff_filepair *p = q->queue[i];
|
||||
int len1, len2;
|
||||
|
@ -3423,7 +3418,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
|
|||
xecfg.ctxlen = 3;
|
||||
xecfg.flags = XDL_EMIT_FUNCNAMES;
|
||||
xdi_diff_outf(&mf1, &mf2, patch_id_consume, &data,
|
||||
&xpp, &xecfg, &ecb);
|
||||
&xpp, &xecfg);
|
||||
}
|
||||
|
||||
git_SHA1_Final(sha1, &ctx);
|
||||
|
|
|
@ -138,19 +138,20 @@ int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t co
|
|||
|
||||
int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
|
||||
xdiff_emit_consume_fn fn, void *consume_callback_data,
|
||||
xpparam_t const *xpp,
|
||||
xdemitconf_t const *xecfg, xdemitcb_t *xecb)
|
||||
xpparam_t const *xpp, xdemitconf_t const *xecfg)
|
||||
{
|
||||
int ret;
|
||||
struct xdiff_emit_state state;
|
||||
xdemitcb_t ecb;
|
||||
|
||||
memset(&state, 0, sizeof(state));
|
||||
state.consume = fn;
|
||||
state.consume_callback_data = consume_callback_data;
|
||||
xecb->outf = xdiff_outf;
|
||||
xecb->priv = &state;
|
||||
memset(&ecb, 0, sizeof(ecb));
|
||||
ecb.outf = xdiff_outf;
|
||||
ecb.priv = &state;
|
||||
strbuf_init(&state.remainder, 0);
|
||||
ret = xdi_diff(mf1, mf2, xpp, xecfg, xecb);
|
||||
ret = xdi_diff(mf1, mf2, xpp, xecfg, &ecb);
|
||||
strbuf_release(&state.remainder);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -9,8 +9,7 @@ typedef void (*xdiff_emit_hunk_consume_fn)(void *, long, long, long);
|
|||
int xdi_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, xdemitconf_t const *xecfg, xdemitcb_t *ecb);
|
||||
int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
|
||||
xdiff_emit_consume_fn fn, void *consume_callback_data,
|
||||
xpparam_t const *xpp,
|
||||
xdemitconf_t const *xecfg, xdemitcb_t *xecb);
|
||||
xpparam_t const *xpp, xdemitconf_t const *xecfg);
|
||||
int xdi_diff_hunks(mmfile_t *mf1, mmfile_t *mf2,
|
||||
xdiff_emit_hunk_consume_fn fn, void *consume_callback_data,
|
||||
xpparam_t const *xpp, xdemitconf_t *xecfg);
|
||||
|
|
Загрузка…
Ссылка в новой задаче