Skip to content

Commit 3d97ea4

Browse files
avargitster
authored andcommitted
*.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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ebf3c04 commit 3d97ea4

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

credential.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ struct credential {
128128
char *path;
129129
};
130130

131-
#define CREDENTIAL_INIT { STRING_LIST_INIT_DUP }
131+
#define CREDENTIAL_INIT { \
132+
.helpers = STRING_LIST_INIT_DUP, \
133+
}
132134

133135
/* Initialize a credential structure, setting all fields to empty. */
134136
void credential_init(struct credential *);

json-writer.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ struct json_writer
6464
unsigned int pretty:1;
6565
};
6666

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+
}
6871

6972
void jw_init(struct json_writer *jw);
7073
void jw_release(struct json_writer *jw);

run-command.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ struct child_process {
141141
void *clean_on_exit_handler_cbdata;
142142
};
143143

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+
}
145148

146149
/**
147150
* The functions: child_process_init, start_command, finish_command,

string-list.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ struct string_list {
9191
compare_strings_fn cmp; /* NULL uses strcmp() */
9292
};
9393

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 }
9696

9797
/* General functions which work with both sorted and unsorted lists. */
9898

0 commit comments

Comments
 (0)