reftable: make assignments portable to AIX xlc v12.01

Change the assignment syntax introduced in 66c0dabab5e (reftable: make reftable_record a tagged union, 2022-01-20) to be portable to AIX xlc v12.1: avar@gcc111:[/home/avar]xlc -qversion IBM XL C/C++ for AIX, V12.1 (5765-J02, 5725-C72) Version: 12.01.0000.0000 The error emitted before this was e.g.: "reftable/generic.c", line 133.26: 1506-196 (S) Initialization between types "char*" and "struct reftable_ref_record" is not allowed. The syntax in the pre-image is supported by e.g. xlc 13.01 on a newer AIX version: avar@gcc119:[/home/avar]xlc -qversion IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07) Version: 13.01.0003.0006 But as we've otherwise supported this compiler let's not break it entirely if it's easy to work around it. Suggested-by: René Scharfe <l.s.r@web.de> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Mar 28, 2022 at 21:10 UTC 33665d98e6bff90896ec5b9f8e8f1223b780a4d1
3 files changed +18 -6
reftable/generic.c
+6 -2
@@ -130,7 +130,9 @@ int reftable_iterator_next_ref(struct reftable_iterator *it,
130 {
131 struct reftable_record rec = {
132 .type = BLOCK_TYPE_REF,
133 - .u.ref = *ref,
133 + .u = {
134 + .ref = *ref
135 + },
136 };
137 int err = iterator_next(it, &rec);
138 *ref = rec.u.ref;
@@ -142,7 +144,9 @@ int reftable_iterator_next_log(struct reftable_iterator *it,
144 {
145 struct reftable_record rec = {
146 .type = BLOCK_TYPE_LOG,
145 - .u.log = *log,
147 + .u = {
148 + .log = *log,
149 + },
150 };
151 int err = iterator_next(it, &rec);
152 *log = rec.u.log;
reftable/record_test.c
+3 -1
@@ -339,7 +339,9 @@ static void test_reftable_obj_record_roundtrip(void)
339 };
340 struct reftable_record in = {
341 .type = BLOCK_TYPE_OBJ,
342 - .u.obj = recs[i],
342 + .u = {
343 + .obj = recs[i],
344 + },
345 };
346 struct strbuf key = STRBUF_INIT;
347 struct reftable_record out = { .type = BLOCK_TYPE_OBJ };
reftable/writer.c
+9 -3
@@ -257,7 +257,9 @@ int reftable_writer_add_ref(struct reftable_writer *w,
257 {
258 struct reftable_record rec = {
259 .type = BLOCK_TYPE_REF,
260 - .u.ref = *ref,
260 + .u = {
261 + .ref = *ref
262 + },
263 };
264 int err = 0;
265
@@ -308,7 +310,9 @@ static int reftable_writer_add_log_verbatim(struct reftable_writer *w,
310 {
311 struct reftable_record rec = {
312 .type = BLOCK_TYPE_LOG,
311 - .u.log = *log,
313 + .u = {
314 + .log = *log,
315 + },
316 };
317 if (w->block_writer &&
318 block_writer_type(w->block_writer) == BLOCK_TYPE_REF) {
@@ -401,7 +405,9 @@ static int writer_finish_section(struct reftable_writer *w)
405 for (i = 0; i < idx_len; i++) {
406 struct reftable_record rec = {
407 .type = BLOCK_TYPE_INDEX,
404 - .u.idx = idx[i],
408 + .u = {
409 + .idx = idx[i],
410 + },
411 };
412 if (block_writer_add(w->block_writer, &rec) == 0) {
413 continue;