Skip to content

Commit 33665d9

Browse files
avargitster
authored andcommitted
reftable: make assignments portable to AIX xlc v12.01
Change the assignment syntax introduced in 66c0dab (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 <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent abf474a commit 33665d9

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

reftable/generic.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ int reftable_iterator_next_ref(struct reftable_iterator *it,
130130
{
131131
struct reftable_record rec = {
132132
.type = BLOCK_TYPE_REF,
133-
.u.ref = *ref,
133+
.u = {
134+
.ref = *ref
135+
},
134136
};
135137
int err = iterator_next(it, &rec);
136138
*ref = rec.u.ref;
@@ -142,7 +144,9 @@ int reftable_iterator_next_log(struct reftable_iterator *it,
142144
{
143145
struct reftable_record rec = {
144146
.type = BLOCK_TYPE_LOG,
145-
.u.log = *log,
147+
.u = {
148+
.log = *log,
149+
},
146150
};
147151
int err = iterator_next(it, &rec);
148152
*log = rec.u.log;

reftable/record_test.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ static void test_reftable_obj_record_roundtrip(void)
339339
};
340340
struct reftable_record in = {
341341
.type = BLOCK_TYPE_OBJ,
342-
.u.obj = recs[i],
342+
.u = {
343+
.obj = recs[i],
344+
},
343345
};
344346
struct strbuf key = STRBUF_INIT;
345347
struct reftable_record out = { .type = BLOCK_TYPE_OBJ };

reftable/writer.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ int reftable_writer_add_ref(struct reftable_writer *w,
257257
{
258258
struct reftable_record rec = {
259259
.type = BLOCK_TYPE_REF,
260-
.u.ref = *ref,
260+
.u = {
261+
.ref = *ref
262+
},
261263
};
262264
int err = 0;
263265

@@ -308,7 +310,9 @@ static int reftable_writer_add_log_verbatim(struct reftable_writer *w,
308310
{
309311
struct reftable_record rec = {
310312
.type = BLOCK_TYPE_LOG,
311-
.u.log = *log,
313+
.u = {
314+
.log = *log,
315+
},
312316
};
313317
if (w->block_writer &&
314318
block_writer_type(w->block_writer) == BLOCK_TYPE_REF) {
@@ -401,7 +405,9 @@ static int writer_finish_section(struct reftable_writer *w)
401405
for (i = 0; i < idx_len; i++) {
402406
struct reftable_record rec = {
403407
.type = BLOCK_TYPE_INDEX,
404-
.u.idx = idx[i],
408+
.u = {
409+
.idx = idx[i],
410+
},
405411
};
406412
if (block_writer_add(w->block_writer, &rec) == 0) {
407413
continue;

0 commit comments

Comments
 (0)