Skip to content

Commit 20d34c0

Browse files
committed
Merge branch 'ab/c99-designated-initializers'
Use designated initializers we started using in mid 2017 in more parts of the codebase that are relatively quiescent. * ab/c99-designated-initializers: fast-import.c: use designated initializers for "partial" struct assignments refspec.c: use designated initializers for "struct refspec_item" convert.c: use designated initializers for "struct stream_filter*" userdiff.c: use designated initializers for "struct userdiff_driver" archive-*.c: use designated initializers for "struct archiver" object-file: use designated initializers for "struct git_hash_algo" trace2: use designated initializers for "struct tr2_dst" trace2: use designated initializers for "struct tr2_tgt" imap-send.c: use designated initializers for "struct imap_server_conf"
2 parents 283e4e7 + c829f5f commit 20d34c0

File tree

11 files changed

+193
-183
lines changed

11 files changed

+193
-183
lines changed

archive-tar.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,9 @@ static int write_tar_filter_archive(const struct archiver *ar,
461461
}
462462

463463
static struct archiver tar_archiver = {
464-
"tar",
465-
write_tar_archive,
466-
ARCHIVER_REMOTE
464+
.name = "tar",
465+
.write_archive = write_tar_archive,
466+
.flags = ARCHIVER_REMOTE,
467467
};
468468

469469
void init_tar_archiver(void)

archive-zip.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,9 @@ static int write_zip_archive(const struct archiver *ar,
638638
}
639639

640640
static struct archiver zip_archiver = {
641-
"zip",
642-
write_zip_archive,
643-
ARCHIVER_WANT_COMPRESSION_LEVELS|ARCHIVER_REMOTE
641+
.name = "zip",
642+
.write_archive = write_zip_archive,
643+
.flags = ARCHIVER_WANT_COMPRESSION_LEVELS|ARCHIVER_REMOTE,
644644
};
645645

646646
void init_zip_archiver(void)

builtin/fast-import.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,9 @@ static int global_argc;
177177
static const char **global_argv;
178178

179179
/* Memory pools */
180-
static struct mem_pool fi_mem_pool = {NULL, 2*1024*1024 -
181-
sizeof(struct mp_block), 0 };
180+
static struct mem_pool fi_mem_pool = {
181+
.block_alloc = 2*1024*1024 - sizeof(struct mp_block),
182+
};
182183

183184
/* Atom management */
184185
static unsigned int atom_table_sz = 4451;
@@ -206,7 +207,9 @@ static int import_marks_file_done;
206207
static int relative_marks_paths;
207208

208209
/* Our last blob */
209-
static struct last_object last_blob = { STRBUF_INIT, 0, 0, 0 };
210+
static struct last_object last_blob = {
211+
.data = STRBUF_INIT,
212+
};
210213

211214
/* Tree management */
212215
static unsigned int tree_entry_alloc = 1000;
@@ -232,7 +235,10 @@ static struct tag *last_tag;
232235
static whenspec_type whenspec = WHENSPEC_RAW;
233236
static struct strbuf command_buf = STRBUF_INIT;
234237
static int unread_command_buf;
235-
static struct recent_command cmd_hist = {&cmd_hist, &cmd_hist, NULL};
238+
static struct recent_command cmd_hist = {
239+
.prev = &cmd_hist,
240+
.next = &cmd_hist,
241+
};
236242
static struct recent_command *cmd_tail = &cmd_hist;
237243
static struct recent_command *rc_free;
238244
static unsigned int cmd_save = 100;

convert.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,12 +1574,12 @@ static void null_free_fn(struct stream_filter *filter)
15741574
}
15751575

15761576
static struct stream_filter_vtbl null_vtbl = {
1577-
null_filter_fn,
1578-
null_free_fn,
1577+
.filter = null_filter_fn,
1578+
.free = null_free_fn,
15791579
};
15801580

15811581
static struct stream_filter null_filter_singleton = {
1582-
&null_vtbl,
1582+
.vtbl = &null_vtbl,
15831583
};
15841584

15851585
int is_null_stream_filter(struct stream_filter *filter)
@@ -1683,8 +1683,8 @@ static void lf_to_crlf_free_fn(struct stream_filter *filter)
16831683
}
16841684

16851685
static struct stream_filter_vtbl lf_to_crlf_vtbl = {
1686-
lf_to_crlf_filter_fn,
1687-
lf_to_crlf_free_fn,
1686+
.filter = lf_to_crlf_filter_fn,
1687+
.free = lf_to_crlf_free_fn,
16881688
};
16891689

16901690
static struct stream_filter *lf_to_crlf_filter(void)
@@ -1779,8 +1779,8 @@ static void cascade_free_fn(struct stream_filter *filter)
17791779
}
17801780

17811781
static struct stream_filter_vtbl cascade_vtbl = {
1782-
cascade_filter_fn,
1783-
cascade_free_fn,
1782+
.filter = cascade_filter_fn,
1783+
.free = cascade_free_fn,
17841784
};
17851785

17861786
static struct stream_filter *cascade_filter(struct stream_filter *one,
@@ -1931,8 +1931,8 @@ static void ident_free_fn(struct stream_filter *filter)
19311931
}
19321932

19331933
static struct stream_filter_vtbl ident_vtbl = {
1934-
ident_filter_fn,
1935-
ident_free_fn,
1934+
.filter = ident_filter_fn,
1935+
.free = ident_free_fn,
19361936
};
19371937

19381938
static struct stream_filter *ident_filter(const struct object_id *oid)

imap-send.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,7 @@ struct imap_server_conf {
9898
};
9999

100100
static struct imap_server_conf server = {
101-
NULL, /* name */
102-
NULL, /* tunnel */
103-
NULL, /* host */
104-
0, /* port */
105-
NULL, /* folder */
106-
NULL, /* user */
107-
NULL, /* pass */
108-
0, /* use_ssl */
109-
1, /* ssl_verify */
110-
0, /* use_html */
111-
NULL, /* auth_method */
101+
.ssl_verify = 1,
112102
};
113103

114104
struct imap_socket {

object-file.c

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -167,49 +167,49 @@ static void git_hash_unknown_final_oid(struct object_id *oid, git_hash_ctx *ctx)
167167

168168
const struct git_hash_algo hash_algos[GIT_HASH_NALGOS] = {
169169
{
170-
NULL,
171-
0x00000000,
172-
0,
173-
0,
174-
0,
175-
git_hash_unknown_init,
176-
git_hash_unknown_clone,
177-
git_hash_unknown_update,
178-
git_hash_unknown_final,
179-
git_hash_unknown_final_oid,
180-
NULL,
181-
NULL,
182-
NULL,
170+
.name = NULL,
171+
.format_id = 0x00000000,
172+
.rawsz = 0,
173+
.hexsz = 0,
174+
.blksz = 0,
175+
.init_fn = git_hash_unknown_init,
176+
.clone_fn = git_hash_unknown_clone,
177+
.update_fn = git_hash_unknown_update,
178+
.final_fn = git_hash_unknown_final,
179+
.final_oid_fn = git_hash_unknown_final_oid,
180+
.empty_tree = NULL,
181+
.empty_blob = NULL,
182+
.null_oid = NULL,
183183
},
184184
{
185-
"sha1",
186-
GIT_SHA1_FORMAT_ID,
187-
GIT_SHA1_RAWSZ,
188-
GIT_SHA1_HEXSZ,
189-
GIT_SHA1_BLKSZ,
190-
git_hash_sha1_init,
191-
git_hash_sha1_clone,
192-
git_hash_sha1_update,
193-
git_hash_sha1_final,
194-
git_hash_sha1_final_oid,
195-
&empty_tree_oid,
196-
&empty_blob_oid,
197-
&null_oid_sha1,
185+
.name = "sha1",
186+
.format_id = GIT_SHA1_FORMAT_ID,
187+
.rawsz = GIT_SHA1_RAWSZ,
188+
.hexsz = GIT_SHA1_HEXSZ,
189+
.blksz = GIT_SHA1_BLKSZ,
190+
.init_fn = git_hash_sha1_init,
191+
.clone_fn = git_hash_sha1_clone,
192+
.update_fn = git_hash_sha1_update,
193+
.final_fn = git_hash_sha1_final,
194+
.final_oid_fn = git_hash_sha1_final_oid,
195+
.empty_tree = &empty_tree_oid,
196+
.empty_blob = &empty_blob_oid,
197+
.null_oid = &null_oid_sha1,
198198
},
199199
{
200-
"sha256",
201-
GIT_SHA256_FORMAT_ID,
202-
GIT_SHA256_RAWSZ,
203-
GIT_SHA256_HEXSZ,
204-
GIT_SHA256_BLKSZ,
205-
git_hash_sha256_init,
206-
git_hash_sha256_clone,
207-
git_hash_sha256_update,
208-
git_hash_sha256_final,
209-
git_hash_sha256_final_oid,
210-
&empty_tree_oid_sha256,
211-
&empty_blob_oid_sha256,
212-
&null_oid_sha256,
200+
.name = "sha256",
201+
.format_id = GIT_SHA256_FORMAT_ID,
202+
.rawsz = GIT_SHA256_RAWSZ,
203+
.hexsz = GIT_SHA256_HEXSZ,
204+
.blksz = GIT_SHA256_BLKSZ,
205+
.init_fn = git_hash_sha256_init,
206+
.clone_fn = git_hash_sha256_clone,
207+
.update_fn = git_hash_sha256_update,
208+
.final_fn = git_hash_sha256_final,
209+
.final_oid_fn = git_hash_sha256_final_oid,
210+
.empty_tree = &empty_tree_oid_sha256,
211+
.empty_blob = &empty_blob_oid_sha256,
212+
.null_oid = &null_oid_sha256,
213213
}
214214
};
215215

refspec.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
#include "refspec.h"
55

66
static struct refspec_item s_tag_refspec = {
7-
0,
8-
1,
9-
0,
10-
0,
11-
0,
12-
"refs/tags/*",
13-
"refs/tags/*"
7+
.force = 0,
8+
.pattern = 1,
9+
.matching = 0,
10+
.exact_sha1 = 0,
11+
.negative = 0,
12+
.src = "refs/tags/*",
13+
.dst = "refs/tags/*",
1414
};
1515

1616
/* See TAG_REFSPEC for the string version */

trace2/tr2_tgt_event.c

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include "trace2/tr2_tgt.h"
1111
#include "trace2/tr2_tls.h"
1212

13-
static struct tr2_dst tr2dst_event = { TR2_SYSENV_EVENT, 0, 0, 0, 0 };
13+
static struct tr2_dst tr2dst_event = {
14+
.sysenv_var = TR2_SYSENV_EVENT,
15+
};
1416

1517
/*
1618
* The version number of the JSON data generated by the EVENT target in this
@@ -613,34 +615,34 @@ static void fn_data_json_fl(const char *file, int line,
613615
}
614616

615617
struct tr2_tgt tr2_tgt_event = {
616-
&tr2dst_event,
617-
618-
fn_init,
619-
fn_term,
620-
621-
fn_version_fl,
622-
fn_start_fl,
623-
fn_exit_fl,
624-
fn_signal,
625-
fn_atexit,
626-
fn_error_va_fl,
627-
fn_command_path_fl,
628-
fn_command_ancestry_fl,
629-
fn_command_name_fl,
630-
fn_command_mode_fl,
631-
fn_alias_fl,
632-
fn_child_start_fl,
633-
fn_child_exit_fl,
634-
fn_child_ready_fl,
635-
fn_thread_start_fl,
636-
fn_thread_exit_fl,
637-
fn_exec_fl,
638-
fn_exec_result_fl,
639-
fn_param_fl,
640-
fn_repo_fl,
641-
fn_region_enter_printf_va_fl,
642-
fn_region_leave_printf_va_fl,
643-
fn_data_fl,
644-
fn_data_json_fl,
645-
NULL, /* printf */
618+
.pdst = &tr2dst_event,
619+
620+
.pfn_init = fn_init,
621+
.pfn_term = fn_term,
622+
623+
.pfn_version_fl = fn_version_fl,
624+
.pfn_start_fl = fn_start_fl,
625+
.pfn_exit_fl = fn_exit_fl,
626+
.pfn_signal = fn_signal,
627+
.pfn_atexit = fn_atexit,
628+
.pfn_error_va_fl = fn_error_va_fl,
629+
.pfn_command_path_fl = fn_command_path_fl,
630+
.pfn_command_ancestry_fl = fn_command_ancestry_fl,
631+
.pfn_command_name_fl = fn_command_name_fl,
632+
.pfn_command_mode_fl = fn_command_mode_fl,
633+
.pfn_alias_fl = fn_alias_fl,
634+
.pfn_child_start_fl = fn_child_start_fl,
635+
.pfn_child_exit_fl = fn_child_exit_fl,
636+
.pfn_child_ready_fl = fn_child_ready_fl,
637+
.pfn_thread_start_fl = fn_thread_start_fl,
638+
.pfn_thread_exit_fl = fn_thread_exit_fl,
639+
.pfn_exec_fl = fn_exec_fl,
640+
.pfn_exec_result_fl = fn_exec_result_fl,
641+
.pfn_param_fl = fn_param_fl,
642+
.pfn_repo_fl = fn_repo_fl,
643+
.pfn_region_enter_printf_va_fl = fn_region_enter_printf_va_fl,
644+
.pfn_region_leave_printf_va_fl = fn_region_leave_printf_va_fl,
645+
.pfn_data_fl = fn_data_fl,
646+
.pfn_data_json_fl = fn_data_json_fl,
647+
.pfn_printf_va_fl = NULL,
646648
};

trace2/tr2_tgt_normal.c

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#include "trace2/tr2_tgt.h"
1010
#include "trace2/tr2_tls.h"
1111

12-
static struct tr2_dst tr2dst_normal = { TR2_SYSENV_NORMAL, 0, 0, 0, 0 };
12+
static struct tr2_dst tr2dst_normal = {
13+
.sysenv_var = TR2_SYSENV_NORMAL,
14+
};
1315

1416
/*
1517
* Use the TR2_SYSENV_NORMAL_BRIEF setting to omit the "<time> <file>:<line>"
@@ -325,34 +327,34 @@ static void fn_printf_va_fl(const char *file, int line,
325327
}
326328

327329
struct tr2_tgt tr2_tgt_normal = {
328-
&tr2dst_normal,
329-
330-
fn_init,
331-
fn_term,
332-
333-
fn_version_fl,
334-
fn_start_fl,
335-
fn_exit_fl,
336-
fn_signal,
337-
fn_atexit,
338-
fn_error_va_fl,
339-
fn_command_path_fl,
340-
fn_command_ancestry_fl,
341-
fn_command_name_fl,
342-
fn_command_mode_fl,
343-
fn_alias_fl,
344-
fn_child_start_fl,
345-
fn_child_exit_fl,
346-
fn_child_ready_fl,
347-
NULL, /* thread_start */
348-
NULL, /* thread_exit */
349-
fn_exec_fl,
350-
fn_exec_result_fl,
351-
fn_param_fl,
352-
fn_repo_fl,
353-
NULL, /* region_enter */
354-
NULL, /* region_leave */
355-
NULL, /* data */
356-
NULL, /* data_json */
357-
fn_printf_va_fl,
330+
.pdst = &tr2dst_normal,
331+
332+
.pfn_init = fn_init,
333+
.pfn_term = fn_term,
334+
335+
.pfn_version_fl = fn_version_fl,
336+
.pfn_start_fl = fn_start_fl,
337+
.pfn_exit_fl = fn_exit_fl,
338+
.pfn_signal = fn_signal,
339+
.pfn_atexit = fn_atexit,
340+
.pfn_error_va_fl = fn_error_va_fl,
341+
.pfn_command_path_fl = fn_command_path_fl,
342+
.pfn_command_ancestry_fl = fn_command_ancestry_fl,
343+
.pfn_command_name_fl = fn_command_name_fl,
344+
.pfn_command_mode_fl = fn_command_mode_fl,
345+
.pfn_alias_fl = fn_alias_fl,
346+
.pfn_child_start_fl = fn_child_start_fl,
347+
.pfn_child_exit_fl = fn_child_exit_fl,
348+
.pfn_child_ready_fl = fn_child_ready_fl,
349+
.pfn_thread_start_fl = NULL,
350+
.pfn_thread_exit_fl = NULL,
351+
.pfn_exec_fl = fn_exec_fl,
352+
.pfn_exec_result_fl = fn_exec_result_fl,
353+
.pfn_param_fl = fn_param_fl,
354+
.pfn_repo_fl = fn_repo_fl,
355+
.pfn_region_enter_printf_va_fl = NULL,
356+
.pfn_region_leave_printf_va_fl = NULL,
357+
.pfn_data_fl = NULL,
358+
.pfn_data_json_fl = NULL,
359+
.pfn_printf_va_fl = fn_printf_va_fl,
358360
};

0 commit comments

Comments
 (0)