Skip to content

Commit 608cfd3

Browse files
avargitster
authored andcommitted
*.h _INIT macros: don't specify fields equal to 0
Change the initialization of "struct strbuf" changed in cbc0f81 (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 59c7b88 (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 c90be78 (test-tool run-command: fix flip-flop init pattern, 2021-09-11). 1. https://lore.kernel.org/git/[email protected]/ Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9865b6e commit 608cfd3

File tree

7 files changed

+7
-11
lines changed

7 files changed

+7
-11
lines changed

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,7 @@ struct cache_def {
16681668
int track_flags;
16691669
int prefix_len_stat_func;
16701670
};
1671-
#define CACHE_DEF_INIT { STRBUF_INIT, 0, 0, 0 }
1671+
#define CACHE_DEF_INIT { STRBUF_INIT }
16721672
static inline void cache_def_clear(struct cache_def *cache)
16731673
{
16741674
strbuf_release(&cache->path);

simple-ipc.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ struct ipc_client_connect_options {
6565
unsigned int uds_disallow_chdir:1;
6666
};
6767

68-
#define IPC_CLIENT_CONNECT_OPTIONS_INIT { \
69-
.wait_if_busy = 0, \
70-
.wait_if_not_found = 0, \
71-
.uds_disallow_chdir = 0, \
72-
}
68+
#define IPC_CLIENT_CONNECT_OPTIONS_INIT { 0 }
7369

7470
/*
7571
* Determine if a server is listening on this named pipe or socket using

strbuf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct strbuf {
7070
};
7171

7272
extern char strbuf_slopbuf[];
73-
#define STRBUF_INIT { .alloc = 0, .len = 0, .buf = strbuf_slopbuf }
73+
#define STRBUF_INIT { .buf = strbuf_slopbuf }
7474

7575
/*
7676
* Predeclare this here, since cache.h includes this file before it defines the

strvec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct strvec {
3333
size_t alloc;
3434
};
3535

36-
#define STRVEC_INIT { empty_strvec, 0, 0 }
36+
#define STRVEC_INIT { empty_strvec }
3737

3838
/**
3939
* Initialize an array. This is no different than assigning from

submodule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct submodule_update_strategy {
3737
enum submodule_update_type type;
3838
const char *command;
3939
};
40-
#define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED, NULL}
40+
#define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED}
4141

4242
int is_gitmodules_unmerged(struct index_state *istate);
4343
int is_writing_gitmodules_ok(void);

t/helper/test-run-command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct testsuite {
6161
int quiet, immediate, verbose, verbose_log, trace, write_junit_xml;
6262
};
6363
#define TESTSUITE_INIT \
64-
{ STRING_LIST_INIT_DUP, STRING_LIST_INIT_DUP, 0, 0, 0, 0, 0, 0, 0 }
64+
{ STRING_LIST_INIT_DUP, STRING_LIST_INIT_DUP }
6565

6666
static int next_test(struct child_process *cp, struct strbuf *err, void *cb,
6767
void **task_cb)

trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ struct trace_key {
8989

9090
extern struct trace_key trace_default_key;
9191

92-
#define TRACE_KEY_INIT(name) { "GIT_TRACE_" #name, 0, 0, 0 }
92+
#define TRACE_KEY_INIT(name) { "GIT_TRACE_" #name }
9393
extern struct trace_key trace_perf_key;
9494
extern struct trace_key trace_setup_key;
9595

0 commit comments

Comments
 (0)