From 9d444d9ee019cb795e6a677fbb70daf6ae64a073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Mon, 27 Sep 2021 14:54:24 +0200 Subject: submodule-config.h: remove unused SUBMODULE_INIT macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This macro was added and used in c68f8375760 (implement fetching of moved submodules, 2017-10-16) but its last user went away in be76c212823 (fetch: ensure submodule objects fetched, 2018-12-06). Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- submodule-config.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/submodule-config.h b/submodule-config.h index c11e22cf50..65875b94ea 100644 --- a/submodule-config.h +++ b/submodule-config.h @@ -45,10 +45,6 @@ struct submodule { struct object_id gitmodules_oid; int recommend_shallow; }; - -#define SUBMODULE_INIT { NULL, NULL, NULL, RECURSE_SUBMODULES_NONE, \ - NULL, NULL, SUBMODULE_UPDATE_STRATEGY_INIT, { { 0 } }, -1 }; - struct submodule_cache; struct repository; -- cgit v1.2.3 From 9865b6e6a4ca1e895fd473c827cf1822f3bd8249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Mon, 27 Sep 2021 14:54:25 +0200 Subject: *.[ch] *_INIT macros: use { 0 } for a "zero out" idiom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In C it isn't required to specify that all members of a struct are zero'd out to 0, NULL or '\0', just providing a "{ 0 }" will accomplish that. Let's also change code that provided N zero'd fields to just provide one, and change e.g. "{ NULL }" to "{ 0 }" for consistency. I.e. even if the first member is a pointer let's use "0" instead of "NULL". The point of using "0" consistently is to pick one, and to not have the reader wonder why we're not using the same pattern everywhere. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 16 ++++++++-------- checkout.c | 2 +- .../gnome-keyring/git-credential-gnome-keyring.c | 2 +- contrib/credential/libsecret/git-credential-libsecret.c | 2 +- diff.c | 4 ++-- lockfile.h | 2 +- object-store.h | 2 +- object.h | 2 +- oid-array.h | 2 +- path.h | 5 +---- ref-filter.c | 2 +- remote.c | 2 +- revision.c | 2 +- 13 files changed, 21 insertions(+), 24 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 5336daf186..deca75c83e 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -307,7 +307,7 @@ struct module_list { const struct cache_entry **entries; int alloc, nr; }; -#define MODULE_LIST_INIT { NULL, 0, 0 } +#define MODULE_LIST_INIT { 0 } static int module_list_compute(int argc, const char **argv, const char *prefix, @@ -588,7 +588,7 @@ struct init_cb { const char *prefix; unsigned int flags; }; -#define INIT_CB_INIT { NULL, 0 } +#define INIT_CB_INIT { 0 } static void init_submodule(const char *path, const char *prefix, unsigned int flags) @@ -717,7 +717,7 @@ struct status_cb { const char *prefix; unsigned int flags; }; -#define STATUS_CB_INIT { NULL, 0 } +#define STATUS_CB_INIT { 0 } static void print_status(unsigned int flags, char state, const char *path, const struct object_id *oid, const char *displaypath) @@ -911,13 +911,13 @@ struct module_cb { char status; const char *sm_path; }; -#define MODULE_CB_INIT { 0, 0, NULL, NULL, '\0', NULL } +#define MODULE_CB_INIT { 0 } struct module_cb_list { struct module_cb **entries; int alloc, nr; }; -#define MODULE_CB_LIST_INIT { NULL, 0, 0 } +#define MODULE_CB_LIST_INIT { 0 } struct summary_cb { int argc; @@ -928,7 +928,7 @@ struct summary_cb { unsigned int files: 1; int summary_limit; }; -#define SUMMARY_CB_INIT { 0, NULL, NULL, 0, 0, 0, 0 } +#define SUMMARY_CB_INIT { 0 } enum diff_cmd { DIFF_INDEX, @@ -1334,7 +1334,7 @@ struct sync_cb { const char *prefix; unsigned int flags; }; -#define SYNC_CB_INIT { NULL, 0 } +#define SYNC_CB_INIT { 0 } static void sync_submodule(const char *path, const char *prefix, unsigned int flags) @@ -1480,7 +1480,7 @@ struct deinit_cb { const char *prefix; unsigned int flags; }; -#define DEINIT_CB_INIT { NULL, 0 } +#define DEINIT_CB_INIT { 0 } static void deinit_submodule(const char *path, const char *prefix, unsigned int flags) diff --git a/checkout.c b/checkout.c index 6586e30ca5..2e39dae684 100644 --- a/checkout.c +++ b/checkout.c @@ -14,7 +14,7 @@ struct tracking_name_data { struct object_id *default_dst_oid; }; -#define TRACKING_NAME_DATA_INIT { NULL, NULL, NULL, 0, NULL, NULL, NULL } +#define TRACKING_NAME_DATA_INIT { 0 } static int check_tracking_name(struct remote *remote, void *cb_data) { diff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c index d389bfadce..5927e27ae6 100644 --- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c +++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c @@ -138,7 +138,7 @@ struct credential { char *password; }; -#define CREDENTIAL_INIT { NULL, NULL, 0, NULL, NULL, NULL } +#define CREDENTIAL_INIT { 0 } typedef int (*credential_op_cb)(struct credential *); diff --git a/contrib/credential/libsecret/git-credential-libsecret.c b/contrib/credential/libsecret/git-credential-libsecret.c index e6598b6383..2c5d76d789 100644 --- a/contrib/credential/libsecret/git-credential-libsecret.c +++ b/contrib/credential/libsecret/git-credential-libsecret.c @@ -41,7 +41,7 @@ struct credential { char *password; }; -#define CREDENTIAL_INIT { NULL, NULL, 0, NULL, NULL, NULL } +#define CREDENTIAL_INIT { 0 } typedef int (*credential_op_cb)(struct credential *); diff --git a/diff.c b/diff.c index c8f530ffdb..861282db1c 100644 --- a/diff.c +++ b/diff.c @@ -775,13 +775,13 @@ struct emitted_diff_symbol { int indent_width; /* The visual width of the indentation */ enum diff_symbol s; }; -#define EMITTED_DIFF_SYMBOL_INIT {NULL} +#define EMITTED_DIFF_SYMBOL_INIT { 0 } struct emitted_diff_symbols { struct emitted_diff_symbol *buf; int nr, alloc; }; -#define EMITTED_DIFF_SYMBOLS_INIT {NULL, 0, 0} +#define EMITTED_DIFF_SYMBOLS_INIT { 0 } static void append_emitted_diff_symbol(struct diff_options *o, struct emitted_diff_symbol *e) diff --git a/lockfile.h b/lockfile.h index db93e6ba73..90af4e66b2 100644 --- a/lockfile.h +++ b/lockfile.h @@ -121,7 +121,7 @@ struct lock_file { struct tempfile *tempfile; }; -#define LOCK_INIT { NULL } +#define LOCK_INIT { 0 } /* String appended to a filename to derive the lockfile name: */ #define LOCK_SUFFIX ".lock" diff --git a/object-store.h b/object-store.h index c5130d8bae..1e647a5be3 100644 --- a/object-store.h +++ b/object-store.h @@ -371,7 +371,7 @@ struct object_info { * Initializer for a "struct object_info" that wants no items. You may * also memset() the memory to all-zeroes. */ -#define OBJECT_INFO_INIT {NULL} +#define OBJECT_INFO_INIT { 0 } /* Invoke lookup_replace_object() on the given hash */ #define OBJECT_INFO_LOOKUP_REPLACE 1 diff --git a/object.h b/object.h index 549f2d256b..cb556ab775 100644 --- a/object.h +++ b/object.h @@ -55,7 +55,7 @@ struct object_array { } *objects; }; -#define OBJECT_ARRAY_INIT { 0, 0, NULL } +#define OBJECT_ARRAY_INIT { 0 } /* * object flag allocation: diff --git a/oid-array.h b/oid-array.h index 72bca78b7d..f60f9af674 100644 --- a/oid-array.h +++ b/oid-array.h @@ -56,7 +56,7 @@ struct oid_array { int sorted; }; -#define OID_ARRAY_INIT { NULL, 0, 0, 0 } +#define OID_ARRAY_INIT { 0 } /** * Add an item to the set. The object ID will be placed at the end of the array diff --git a/path.h b/path.h index 251c78d980..b68691a86b 100644 --- a/path.h +++ b/path.h @@ -181,10 +181,7 @@ struct path_cache { const char *shallow; }; -#define PATH_CACHE_INIT \ - { \ - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ - } +#define PATH_CACHE_INIT { 0 } const char *git_path_squash_msg(struct repository *r); const char *git_path_merge_msg(struct repository *r); diff --git a/ref-filter.c b/ref-filter.c index 93ce2a6ef2..eee4f9b17c 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -633,7 +633,7 @@ static struct { */ }; -#define REF_FORMATTING_STATE_INIT { 0, NULL } +#define REF_FORMATTING_STATE_INIT { 0 } struct ref_formatting_stack { struct ref_formatting_stack *prev; diff --git a/remote.c b/remote.c index 31e141b01f..f958543d70 100644 --- a/remote.c +++ b/remote.c @@ -2403,7 +2403,7 @@ struct reflog_commit_array { size_t nr, alloc; }; -#define REFLOG_COMMIT_ARRAY_INIT { NULL, 0, 0 } +#define REFLOG_COMMIT_ARRAY_INIT { 0 } /* Append a commit to the array. */ static void append_commit(struct reflog_commit_array *arr, diff --git a/revision.c b/revision.c index 0dabb5a0bc..73e5004d60 100644 --- a/revision.c +++ b/revision.c @@ -249,7 +249,7 @@ struct commit_stack { struct commit **items; size_t nr, alloc; }; -#define COMMIT_STACK_INIT { NULL, 0, 0 } +#define COMMIT_STACK_INIT { 0 } static void commit_stack_push(struct commit_stack *stack, struct commit *commit) { -- cgit v1.2.3 From 608cfd31cf8179ff971ddaf64675b47187e768c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Mon, 27 Sep 2021 14:54:26 +0200 Subject: *.h _INIT macros: don't specify fields equal to 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change the initialization of "struct strbuf" changed in cbc0f81d96f (strbuf: use designated initializers in STRBUF_INIT, 2017-07-10) to omit specifying "alloc" and "len", as we do with other "alloc" and "len" (or "nr") in similar structs. Let's likewise omit the explicit initialization of all fields in the "struct ipc_client_connect_option" struct added in 59c7b88198a (simple-ipc: add win32 implementation, 2021-03-15). Do the same for a few other initializers, e.g. STRVEC_INIT and CACHE_DEF_INIT. Finally, start incrementally changing the same pattern in "t/helper/test-run-command.c". This change was part of an earlier on-list version[1] of c90be786da9 (test-tool run-command: fix flip-flop init pattern, 2021-09-11). 1. https://lore.kernel.org/git/patch-1.1-0aa4523ab6e-20210909T130849Z-avarab@gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- cache.h | 2 +- simple-ipc.h | 6 +----- strbuf.h | 2 +- strvec.h | 2 +- submodule.h | 2 +- t/helper/test-run-command.c | 2 +- trace.h | 2 +- 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cache.h b/cache.h index f6295f3b04..25c6b0b120 100644 --- a/cache.h +++ b/cache.h @@ -1668,7 +1668,7 @@ struct cache_def { int track_flags; int prefix_len_stat_func; }; -#define CACHE_DEF_INIT { STRBUF_INIT, 0, 0, 0 } +#define CACHE_DEF_INIT { STRBUF_INIT } static inline void cache_def_clear(struct cache_def *cache) { strbuf_release(&cache->path); diff --git a/simple-ipc.h b/simple-ipc.h index 2c48a5ee00..08b2908d5f 100644 --- a/simple-ipc.h +++ b/simple-ipc.h @@ -65,11 +65,7 @@ struct ipc_client_connect_options { unsigned int uds_disallow_chdir:1; }; -#define IPC_CLIENT_CONNECT_OPTIONS_INIT { \ - .wait_if_busy = 0, \ - .wait_if_not_found = 0, \ - .uds_disallow_chdir = 0, \ -} +#define IPC_CLIENT_CONNECT_OPTIONS_INIT { 0 } /* * Determine if a server is listening on this named pipe or socket using diff --git a/strbuf.h b/strbuf.h index 5b1113abf8..3b36bbc49f 100644 --- a/strbuf.h +++ b/strbuf.h @@ -70,7 +70,7 @@ struct strbuf { }; extern char strbuf_slopbuf[]; -#define STRBUF_INIT { .alloc = 0, .len = 0, .buf = strbuf_slopbuf } +#define STRBUF_INIT { .buf = strbuf_slopbuf } /* * Predeclare this here, since cache.h includes this file before it defines the diff --git a/strvec.h b/strvec.h index 6b3cbd6758..a10aad5f64 100644 --- a/strvec.h +++ b/strvec.h @@ -33,7 +33,7 @@ struct strvec { size_t alloc; }; -#define STRVEC_INIT { empty_strvec, 0, 0 } +#define STRVEC_INIT { empty_strvec } /** * Initialize an array. This is no different than assigning from diff --git a/submodule.h b/submodule.h index 4578e501b8..35d18c7868 100644 --- a/submodule.h +++ b/submodule.h @@ -37,7 +37,7 @@ struct submodule_update_strategy { enum submodule_update_type type; const char *command; }; -#define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED, NULL} +#define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED} int is_gitmodules_unmerged(struct index_state *istate); int is_writing_gitmodules_ok(void); diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c index 14c57365e7..50bb98b7e0 100644 --- a/t/helper/test-run-command.c +++ b/t/helper/test-run-command.c @@ -61,7 +61,7 @@ struct testsuite { int quiet, immediate, verbose, verbose_log, trace, write_junit_xml; }; #define TESTSUITE_INIT \ - { STRING_LIST_INIT_DUP, STRING_LIST_INIT_DUP, 0, 0, 0, 0, 0, 0, 0 } + { STRING_LIST_INIT_DUP, STRING_LIST_INIT_DUP } static int next_test(struct child_process *cp, struct strbuf *err, void *cb, void **task_cb) diff --git a/trace.h b/trace.h index 0dbbad0e41..74f62919c5 100644 --- a/trace.h +++ b/trace.h @@ -89,7 +89,7 @@ struct trace_key { extern struct trace_key trace_default_key; -#define TRACE_KEY_INIT(name) { "GIT_TRACE_" #name, 0, 0, 0 } +#define TRACE_KEY_INIT(name) { "GIT_TRACE_" #name } extern struct trace_key trace_perf_key; extern struct trace_key trace_setup_key; -- cgit v1.2.3 From f69a6e4f076ec9ec89d94a6d960d0c161381a597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Mon, 27 Sep 2021 14:54:27 +0200 Subject: *.h: move some *_INIT to designated initializers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move various *_INIT macros to use designated initializers. This helps readability. I've only picked those leftover macros that were not touched by another in-flight series of mine which changed others, but also how initialization was done. In the case of SUBMODULE_ALTERNATE_SETUP_INIT I've left an explicit initialization of "error_mode", even though SUBMODULE_ALTERNATE_ERROR_IGNORE itself is defined as "0". Let's not peek under the hood and assume that enum fields we know the value of will stay at "0". The change to "TESTSUITE_INIT" in "t/helper/test-run-command.c" was part of an earlier on-list version[1] of c90be786da9 (test-tool run-command: fix flip-flop init pattern, 2021-09-11). 1. https://lore.kernel.org/git/patch-1.1-0aa4523ab6e-20210909T130849Z-avarab@gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- add-interactive.c | 8 ++++++-- builtin/submodule--helper.c | 5 +++-- cache.h | 4 +++- entry.h | 2 +- list.h | 5 ++++- sequencer.h | 4 +++- shallow.h | 4 +++- strvec.h | 4 +++- submodule.c | 8 +++++--- submodule.h | 4 +++- t/helper/test-run-command.c | 6 ++++-- trace.h | 2 +- transport.h | 4 +++- 13 files changed, 42 insertions(+), 18 deletions(-) diff --git a/add-interactive.c b/add-interactive.c index 36ebdbdf7e..6498ae196f 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -102,8 +102,12 @@ struct prefix_item_list { int *selected; /* for multi-selections */ size_t min_length, max_length; }; -#define PREFIX_ITEM_LIST_INIT \ - { STRING_LIST_INIT_DUP, STRING_LIST_INIT_NODUP, NULL, 1, 4 } +#define PREFIX_ITEM_LIST_INIT { \ + .items = STRING_LIST_INIT_DUP, \ + .sorted = STRING_LIST_INIT_NODUP, \ + .min_length = 1, \ + .max_length = 4, \ +} static void prefix_item_list_clear(struct prefix_item_list *list) { diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index deca75c83e..57f0992515 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1647,8 +1647,9 @@ struct submodule_alternate_setup { } error_mode; struct string_list *reference; }; -#define SUBMODULE_ALTERNATE_SETUP_INIT { NULL, \ - SUBMODULE_ALTERNATE_ERROR_IGNORE, NULL } +#define SUBMODULE_ALTERNATE_SETUP_INIT { \ + .error_mode = SUBMODULE_ALTERNATE_ERROR_IGNORE, \ +} static const char alternate_error_advice[] = N_( "An alternate computed from a superproject's alternate is invalid.\n" diff --git a/cache.h b/cache.h index 25c6b0b120..794237515b 100644 --- a/cache.h +++ b/cache.h @@ -1668,7 +1668,9 @@ struct cache_def { int track_flags; int prefix_len_stat_func; }; -#define CACHE_DEF_INIT { STRBUF_INIT } +#define CACHE_DEF_INIT { \ + .path = STRBUF_INIT, \ +} static inline void cache_def_clear(struct cache_def *cache) { strbuf_release(&cache->path); diff --git a/entry.h b/entry.h index 7c889e58fd..2254c62727 100644 --- a/entry.h +++ b/entry.h @@ -16,7 +16,7 @@ struct checkout { clone:1, refresh_cache:1; }; -#define CHECKOUT_INIT { NULL, "" } +#define CHECKOUT_INIT { .base_dir = "" } #define TEMPORARY_FILENAME_LENGTH 25 /* diff --git a/list.h b/list.h index eb601192f4..362a4cd7f5 100644 --- a/list.h +++ b/list.h @@ -46,7 +46,10 @@ struct list_head { #define INIT_LIST_HEAD(ptr) \ (ptr)->next = (ptr)->prev = (ptr) -#define LIST_HEAD_INIT(name) { &(name), &(name) } +#define LIST_HEAD_INIT(name) { \ + .next = &(name), \ + .prev = &(name), \ +} /* Add new element at the head of the list. */ static inline void list_add(struct list_head *newp, struct list_head *head) diff --git a/sequencer.h b/sequencer.h index 2088344cb3..259d4eb4a8 100644 --- a/sequencer.h +++ b/sequencer.h @@ -119,7 +119,9 @@ struct todo_list { struct stat_data stat; }; -#define TODO_LIST_INIT { STRBUF_INIT } +#define TODO_LIST_INIT { \ + .buf = STRBUF_INIT, \ +} int todo_list_parse_insn_buffer(struct repository *r, char *buf, struct todo_list *todo_list); diff --git a/shallow.h b/shallow.h index 5b4a96dcd6..aba6ff5829 100644 --- a/shallow.h +++ b/shallow.h @@ -23,7 +23,9 @@ int is_repository_shallow(struct repository *r); struct shallow_lock { struct lock_file lock; }; -#define SHALLOW_LOCK_INIT { LOCK_INIT } +#define SHALLOW_LOCK_INIT { \ + .lock = LOCK_INIT, \ +} /* commit $GIT_DIR/shallow and reset stat-validity checks */ int commit_shallow_file(struct repository *r, struct shallow_lock *lk); diff --git a/strvec.h b/strvec.h index a10aad5f64..9f55c8766b 100644 --- a/strvec.h +++ b/strvec.h @@ -33,7 +33,9 @@ struct strvec { size_t alloc; }; -#define STRVEC_INIT { empty_strvec } +#define STRVEC_INIT { \ + .v = empty_strvec, \ +} /** * Initialize an array. This is no different than assigning from diff --git a/submodule.c b/submodule.c index 78aed03d92..03cf36707a 100644 --- a/submodule.c +++ b/submodule.c @@ -1321,9 +1321,11 @@ struct submodule_parallel_fetch { struct strbuf submodules_with_errors; }; -#define SPF_INIT {0, STRVEC_INIT, NULL, NULL, 0, 0, 0, 0, \ - STRING_LIST_INIT_DUP, \ - NULL, 0, 0, STRBUF_INIT} +#define SPF_INIT { \ + .args = STRVEC_INIT, \ + .changed_submodule_names = STRING_LIST_INIT_DUP, \ + .submodules_with_errors = STRBUF_INIT, \ +} static int get_fetch_recurse_config(const struct submodule *submodule, struct submodule_parallel_fetch *spf) diff --git a/submodule.h b/submodule.h index 35d18c7868..6bd2c99fd9 100644 --- a/submodule.h +++ b/submodule.h @@ -37,7 +37,9 @@ struct submodule_update_strategy { enum submodule_update_type type; const char *command; }; -#define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED} +#define SUBMODULE_UPDATE_STRATEGY_INIT { \ + .type = SM_UPDATE_UNSPECIFIED, \ +} int is_gitmodules_unmerged(struct index_state *istate); int is_writing_gitmodules_ok(void); diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c index 50bb98b7e0..3c4fb86223 100644 --- a/t/helper/test-run-command.c +++ b/t/helper/test-run-command.c @@ -60,8 +60,10 @@ struct testsuite { int next; int quiet, immediate, verbose, verbose_log, trace, write_junit_xml; }; -#define TESTSUITE_INIT \ - { STRING_LIST_INIT_DUP, STRING_LIST_INIT_DUP } +#define TESTSUITE_INIT { \ + .tests = STRING_LIST_INIT_DUP, \ + .failed = STRING_LIST_INIT_DUP, \ +} static int next_test(struct child_process *cp, struct strbuf *err, void *cb, void **task_cb) diff --git a/trace.h b/trace.h index 74f62919c5..e25984051a 100644 --- a/trace.h +++ b/trace.h @@ -89,7 +89,7 @@ struct trace_key { extern struct trace_key trace_default_key; -#define TRACE_KEY_INIT(name) { "GIT_TRACE_" #name } +#define TRACE_KEY_INIT(name) { .key = "GIT_TRACE_" #name } extern struct trace_key trace_perf_key; extern struct trace_key trace_setup_key; diff --git a/transport.h b/transport.h index 1cbab11373..8bb4c8bbc8 100644 --- a/transport.h +++ b/transport.h @@ -262,7 +262,9 @@ struct transport_ls_refs_options { */ char *unborn_head_target; }; -#define TRANSPORT_LS_REFS_OPTIONS_INIT { STRVEC_INIT } +#define TRANSPORT_LS_REFS_OPTIONS_INIT { \ + .ref_prefixes = STRVEC_INIT, \ +} /* * Retrieve refs from a remote. -- cgit v1.2.3 From 538835d2ac151abbe90058becfc0dc061d33302c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Mon, 27 Sep 2021 14:54:28 +0200 Subject: cbtree.h: define cb_init() in terms of CBTREE_INIT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the same pattern for cb_init() as the one established in the recent refactoring of other such patterns in 5726a6b4012 (*.c *_init(): define in terms of corresponding *_INIT macro, 2021-07-01). It has been pointed out[1] that we could perhaps use this C99 replacement of using a compound literal for all of these: *t = (struct cb_tree){ 0 }; But let's just stick to the existing pattern established in 5726a6b4012 for now, we can leave another weather balloon for some other time. 1. http://lore.kernel.org/git/ef724a3a-a4b8-65d3-c928-13a7d78f189a@gmail.com Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- cbtree.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cbtree.h b/cbtree.h index a04a312c3f..dedbb8e2a4 100644 --- a/cbtree.h +++ b/cbtree.h @@ -37,11 +37,12 @@ enum cb_next { CB_BREAK = 1 }; -#define CBTREE_INIT { .root = NULL } +#define CBTREE_INIT { 0 } static inline void cb_init(struct cb_tree *t) { - t->root = NULL; + struct cb_tree blank = CBTREE_INIT; + memcpy(t, &blank, sizeof(*t)); } struct cb_node *cb_lookup(struct cb_tree *, const uint8_t *k, size_t klen); -- cgit v1.2.3