Skip to content

Commit 30b2501

Browse files
dschogitster
authored andcommitted
Future-proof source for changes in xdemitconf_t
The instances of xdemitconf_t were initialized member by member. Instead, initialize them to all zero, so we do not have to update those places each time we introduce a new member. [jc: minimally fixed by getting rid of a new global] Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 29a3eef commit 30b2501

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

builtin-blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,
518518
xdemitcb_t ecb;
519519

520520
xpp.flags = xdl_opts;
521+
memset(&xecfg, 0, sizeof(xecfg));
521522
xecfg.ctxlen = context;
522-
xecfg.flags = 0;
523523
ecb.outf = xdiff_outf;
524524
ecb.priv = &state;
525525
memset(&state, 0, sizeof(state));

builtin-rerere.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ static int diff_two(const char *file1, const char *label1,
282282
printf("--- a/%s\n+++ b/%s\n", label1, label2);
283283
fflush(stdout);
284284
xpp.flags = XDF_NEED_MINIMAL;
285+
memset(&xecfg, 0, sizeof(xecfg));
285286
xecfg.ctxlen = 3;
286-
xecfg.flags = 0;
287287
ecb.outf = outf;
288288
xdl_diff(&minus, &plus, &xpp, &xecfg, &ecb);
289289

combine-diff.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ static void combine_diff(const unsigned char *parent, mmfile_t *result_file,
215215
parent_file.ptr = grab_blob(parent, &sz);
216216
parent_file.size = sz;
217217
xpp.flags = XDF_NEED_MINIMAL;
218-
xecfg.ctxlen = 0;
219-
xecfg.flags = 0;
218+
memset(&xecfg, 0, sizeof(xecfg));
220219
ecb.outf = xdiff_outf;
221220
ecb.priv = &state;
222221
memset(&state, 0, sizeof(state));

diff.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
390390
mmfile_t minus, plus;
391391
int i;
392392

393+
memset(&xecfg, 0, sizeof(xecfg));
393394
minus.size = diff_words->minus.text.size;
394395
minus.ptr = xmalloc(minus.size);
395396
memcpy(minus.ptr, diff_words->minus.text.ptr, minus.size);
@@ -408,7 +409,6 @@ static void diff_words_show(struct diff_words_data *diff_words)
408409

409410
xpp.flags = XDF_NEED_MINIMAL;
410411
xecfg.ctxlen = diff_words->minus.alloc + diff_words->plus.alloc;
411-
xecfg.flags = 0;
412412
ecb.outf = xdiff_outf;
413413
ecb.priv = diff_words;
414414
diff_words->xm.consume = fn_out_diff_words_aux;
@@ -1218,6 +1218,7 @@ static void builtin_diff(const char *name_a,
12181218
xdemitcb_t ecb;
12191219
struct emit_callback ecbdata;
12201220

1221+
memset(&xecfg, 0, sizeof(xecfg));
12211222
memset(&ecbdata, 0, sizeof(ecbdata));
12221223
ecbdata.label_path = lbl;
12231224
ecbdata.color_diff = o->color_diff;
@@ -1286,9 +1287,8 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
12861287
xdemitconf_t xecfg;
12871288
xdemitcb_t ecb;
12881289

1290+
memset(&xecfg, 0, sizeof(xecfg));
12891291
xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
1290-
xecfg.ctxlen = 0;
1291-
xecfg.flags = 0;
12921292
ecb.outf = xdiff_outf;
12931293
ecb.priv = diffstat;
12941294
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
@@ -1326,9 +1326,8 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
13261326
xdemitconf_t xecfg;
13271327
xdemitcb_t ecb;
13281328

1329+
memset(&xecfg, 0, sizeof(xecfg));
13291330
xpp.flags = XDF_NEED_MINIMAL;
1330-
xecfg.ctxlen = 0;
1331-
xecfg.flags = 0;
13321331
ecb.outf = xdiff_outf;
13331332
ecb.priv = &data;
13341333
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
@@ -2780,6 +2779,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
27802779
struct diff_filepair *p = q->queue[i];
27812780
int len1, len2;
27822781

2782+
memset(&xecfg, 0, sizeof(xecfg));
27832783
if (p->status == 0)
27842784
return error("internal diff status error");
27852785
if (p->status == DIFF_STATUS_UNKNOWN)

merge-file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
6262
xdemitcb_t ecb;
6363

6464
xpp.flags = XDF_NEED_MINIMAL;
65+
memset(&xecfg, 0, sizeof(xecfg));
6566
xecfg.ctxlen = 3;
6667
xecfg.flags = XDL_EMIT_COMMON;
6768
ecb.outf = common_outf;

merge-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ static void show_diff(struct merge_list *entry)
106106
xdemitcb_t ecb;
107107

108108
xpp.flags = XDF_NEED_MINIMAL;
109+
memset(&xecfg, 0, sizeof(xecfg));
109110
xecfg.ctxlen = 3;
110-
xecfg.flags = 0;
111111
ecb.outf = show_outf;
112112
ecb.priv = NULL;
113113

0 commit comments

Comments
 (0)