*.h: move some *_INIT to designated initializers
Move *_INIT macros I'll use in a subsequent commits to designated initializers. This isn't required for those follow-up changes, but since next commits will change things in this area, let's use the modern pattern over the old one while we're at it. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Jul 1, 2021 at 12:51 UTC
3d97ea479fdcb88671105e2f2d04064bab110bd5
4 files changed
+13
-5
credential.h
+3
-1
@@ -128,7 +128,9 @@ struct credential {
128
char *path;
129
};
130
131
-#define CREDENTIAL_INIT { STRING_LIST_INIT_DUP }
131
+#define CREDENTIAL_INIT { \
132
+ .helpers = STRING_LIST_INIT_DUP, \
133
+}
134
135
/* Initialize a credential structure, setting all fields to empty. */
136
void credential_init(struct credential *);
json-writer.h
+4
-1
@@ -64,7 +64,10 @@ struct json_writer
64
unsigned int pretty:1;
65
};
66
67
-#define JSON_WRITER_INIT { STRBUF_INIT, STRBUF_INIT, 0, 0 }
67
+#define JSON_WRITER_INIT { \
68
+ .json = STRBUF_INIT, \
69
+ .open_stack = STRBUF_INIT, \
70
+}
71
72
void jw_init(struct json_writer *jw);
73
void jw_release(struct json_writer *jw);
run-command.h
+4
-1
@@ -141,7 +141,10 @@ struct child_process {
141
void *clean_on_exit_handler_cbdata;
142
};
143
144
-#define CHILD_PROCESS_INIT { NULL, STRVEC_INIT, STRVEC_INIT }
144
+#define CHILD_PROCESS_INIT { \
145
+ .args = STRVEC_INIT, \
146
+ .env_array = STRVEC_INIT, \
147
+}
148
149
/**
150
* The functions: child_process_init, start_command, finish_command,
string-list.h
+2
-2
@@ -91,8 +91,8 @@ struct string_list {
91
compare_strings_fn cmp; /* NULL uses strcmp() */
92
};
93
94
-#define STRING_LIST_INIT_NODUP { NULL, 0, 0, 0, NULL }
95
-#define STRING_LIST_INIT_DUP { NULL, 0, 0, 1, NULL }
94
+#define STRING_LIST_INIT_NODUP { 0 }
95
+#define STRING_LIST_INIT_DUP { .strdup_strings = 1 }
96
97
/* General functions which work with both sorted and unsorted lists. */
98