Git fork

*.[ch] *_INIT macros: use { 0 } for a "zero out" idiom

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 <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Ævar Arnfjörð Bjarmason and committed by
Junio C Hamano
9865b6e6 9d444d9e

+21 -24
+8 -8
builtin/submodule--helper.c
··· 307 const struct cache_entry **entries; 308 int alloc, nr; 309 }; 310 - #define MODULE_LIST_INIT { NULL, 0, 0 } 311 312 static int module_list_compute(int argc, const char **argv, 313 const char *prefix, ··· 588 const char *prefix; 589 unsigned int flags; 590 }; 591 - #define INIT_CB_INIT { NULL, 0 } 592 593 static void init_submodule(const char *path, const char *prefix, 594 unsigned int flags) ··· 717 const char *prefix; 718 unsigned int flags; 719 }; 720 - #define STATUS_CB_INIT { NULL, 0 } 721 722 static void print_status(unsigned int flags, char state, const char *path, 723 const struct object_id *oid, const char *displaypath) ··· 911 char status; 912 const char *sm_path; 913 }; 914 - #define MODULE_CB_INIT { 0, 0, NULL, NULL, '\0', NULL } 915 916 struct module_cb_list { 917 struct module_cb **entries; 918 int alloc, nr; 919 }; 920 - #define MODULE_CB_LIST_INIT { NULL, 0, 0 } 921 922 struct summary_cb { 923 int argc; ··· 928 unsigned int files: 1; 929 int summary_limit; 930 }; 931 - #define SUMMARY_CB_INIT { 0, NULL, NULL, 0, 0, 0, 0 } 932 933 enum diff_cmd { 934 DIFF_INDEX, ··· 1334 const char *prefix; 1335 unsigned int flags; 1336 }; 1337 - #define SYNC_CB_INIT { NULL, 0 } 1338 1339 static void sync_submodule(const char *path, const char *prefix, 1340 unsigned int flags) ··· 1480 const char *prefix; 1481 unsigned int flags; 1482 }; 1483 - #define DEINIT_CB_INIT { NULL, 0 } 1484 1485 static void deinit_submodule(const char *path, const char *prefix, 1486 unsigned int flags)
··· 307 const struct cache_entry **entries; 308 int alloc, nr; 309 }; 310 + #define MODULE_LIST_INIT { 0 } 311 312 static int module_list_compute(int argc, const char **argv, 313 const char *prefix, ··· 588 const char *prefix; 589 unsigned int flags; 590 }; 591 + #define INIT_CB_INIT { 0 } 592 593 static void init_submodule(const char *path, const char *prefix, 594 unsigned int flags) ··· 717 const char *prefix; 718 unsigned int flags; 719 }; 720 + #define STATUS_CB_INIT { 0 } 721 722 static void print_status(unsigned int flags, char state, const char *path, 723 const struct object_id *oid, const char *displaypath) ··· 911 char status; 912 const char *sm_path; 913 }; 914 + #define MODULE_CB_INIT { 0 } 915 916 struct module_cb_list { 917 struct module_cb **entries; 918 int alloc, nr; 919 }; 920 + #define MODULE_CB_LIST_INIT { 0 } 921 922 struct summary_cb { 923 int argc; ··· 928 unsigned int files: 1; 929 int summary_limit; 930 }; 931 + #define SUMMARY_CB_INIT { 0 } 932 933 enum diff_cmd { 934 DIFF_INDEX, ··· 1334 const char *prefix; 1335 unsigned int flags; 1336 }; 1337 + #define SYNC_CB_INIT { 0 } 1338 1339 static void sync_submodule(const char *path, const char *prefix, 1340 unsigned int flags) ··· 1480 const char *prefix; 1481 unsigned int flags; 1482 }; 1483 + #define DEINIT_CB_INIT { 0 } 1484 1485 static void deinit_submodule(const char *path, const char *prefix, 1486 unsigned int flags)
+1 -1
checkout.c
··· 14 struct object_id *default_dst_oid; 15 }; 16 17 - #define TRACKING_NAME_DATA_INIT { NULL, NULL, NULL, 0, NULL, NULL, NULL } 18 19 static int check_tracking_name(struct remote *remote, void *cb_data) 20 {
··· 14 struct object_id *default_dst_oid; 15 }; 16 17 + #define TRACKING_NAME_DATA_INIT { 0 } 18 19 static int check_tracking_name(struct remote *remote, void *cb_data) 20 {
+1 -1
contrib/credential/gnome-keyring/git-credential-gnome-keyring.c
··· 138 char *password; 139 }; 140 141 - #define CREDENTIAL_INIT { NULL, NULL, 0, NULL, NULL, NULL } 142 143 typedef int (*credential_op_cb)(struct credential *); 144
··· 138 char *password; 139 }; 140 141 + #define CREDENTIAL_INIT { 0 } 142 143 typedef int (*credential_op_cb)(struct credential *); 144
+1 -1
contrib/credential/libsecret/git-credential-libsecret.c
··· 41 char *password; 42 }; 43 44 - #define CREDENTIAL_INIT { NULL, NULL, 0, NULL, NULL, NULL } 45 46 typedef int (*credential_op_cb)(struct credential *); 47
··· 41 char *password; 42 }; 43 44 + #define CREDENTIAL_INIT { 0 } 45 46 typedef int (*credential_op_cb)(struct credential *); 47
+2 -2
diff.c
··· 775 int indent_width; /* The visual width of the indentation */ 776 enum diff_symbol s; 777 }; 778 - #define EMITTED_DIFF_SYMBOL_INIT {NULL} 779 780 struct emitted_diff_symbols { 781 struct emitted_diff_symbol *buf; 782 int nr, alloc; 783 }; 784 - #define EMITTED_DIFF_SYMBOLS_INIT {NULL, 0, 0} 785 786 static void append_emitted_diff_symbol(struct diff_options *o, 787 struct emitted_diff_symbol *e)
··· 775 int indent_width; /* The visual width of the indentation */ 776 enum diff_symbol s; 777 }; 778 + #define EMITTED_DIFF_SYMBOL_INIT { 0 } 779 780 struct emitted_diff_symbols { 781 struct emitted_diff_symbol *buf; 782 int nr, alloc; 783 }; 784 + #define EMITTED_DIFF_SYMBOLS_INIT { 0 } 785 786 static void append_emitted_diff_symbol(struct diff_options *o, 787 struct emitted_diff_symbol *e)
+1 -1
lockfile.h
··· 121 struct tempfile *tempfile; 122 }; 123 124 - #define LOCK_INIT { NULL } 125 126 /* String appended to a filename to derive the lockfile name: */ 127 #define LOCK_SUFFIX ".lock"
··· 121 struct tempfile *tempfile; 122 }; 123 124 + #define LOCK_INIT { 0 } 125 126 /* String appended to a filename to derive the lockfile name: */ 127 #define LOCK_SUFFIX ".lock"
+1 -1
object-store.h
··· 371 * Initializer for a "struct object_info" that wants no items. You may 372 * also memset() the memory to all-zeroes. 373 */ 374 - #define OBJECT_INFO_INIT {NULL} 375 376 /* Invoke lookup_replace_object() on the given hash */ 377 #define OBJECT_INFO_LOOKUP_REPLACE 1
··· 371 * Initializer for a "struct object_info" that wants no items. You may 372 * also memset() the memory to all-zeroes. 373 */ 374 + #define OBJECT_INFO_INIT { 0 } 375 376 /* Invoke lookup_replace_object() on the given hash */ 377 #define OBJECT_INFO_LOOKUP_REPLACE 1
+1 -1
object.h
··· 55 } *objects; 56 }; 57 58 - #define OBJECT_ARRAY_INIT { 0, 0, NULL } 59 60 /* 61 * object flag allocation:
··· 55 } *objects; 56 }; 57 58 + #define OBJECT_ARRAY_INIT { 0 } 59 60 /* 61 * object flag allocation:
+1 -1
oid-array.h
··· 56 int sorted; 57 }; 58 59 - #define OID_ARRAY_INIT { NULL, 0, 0, 0 } 60 61 /** 62 * Add an item to the set. The object ID will be placed at the end of the array
··· 56 int sorted; 57 }; 58 59 + #define OID_ARRAY_INIT { 0 } 60 61 /** 62 * Add an item to the set. The object ID will be placed at the end of the array
+1 -4
path.h
··· 181 const char *shallow; 182 }; 183 184 - #define PATH_CACHE_INIT \ 185 - { \ 186 - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ 187 - } 188 189 const char *git_path_squash_msg(struct repository *r); 190 const char *git_path_merge_msg(struct repository *r);
··· 181 const char *shallow; 182 }; 183 184 + #define PATH_CACHE_INIT { 0 } 185 186 const char *git_path_squash_msg(struct repository *r); 187 const char *git_path_merge_msg(struct repository *r);
+1 -1
ref-filter.c
··· 633 */ 634 }; 635 636 - #define REF_FORMATTING_STATE_INIT { 0, NULL } 637 638 struct ref_formatting_stack { 639 struct ref_formatting_stack *prev;
··· 633 */ 634 }; 635 636 + #define REF_FORMATTING_STATE_INIT { 0 } 637 638 struct ref_formatting_stack { 639 struct ref_formatting_stack *prev;
+1 -1
remote.c
··· 2403 size_t nr, alloc; 2404 }; 2405 2406 - #define REFLOG_COMMIT_ARRAY_INIT { NULL, 0, 0 } 2407 2408 /* Append a commit to the array. */ 2409 static void append_commit(struct reflog_commit_array *arr,
··· 2403 size_t nr, alloc; 2404 }; 2405 2406 + #define REFLOG_COMMIT_ARRAY_INIT { 0 } 2407 2408 /* Append a commit to the array. */ 2409 static void append_commit(struct reflog_commit_array *arr,
+1 -1
revision.c
··· 249 struct commit **items; 250 size_t nr, alloc; 251 }; 252 - #define COMMIT_STACK_INIT { NULL, 0, 0 } 253 254 static void commit_stack_push(struct commit_stack *stack, struct commit *commit) 255 {
··· 249 struct commit **items; 250 size_t nr, alloc; 251 }; 252 + #define COMMIT_STACK_INIT { 0 } 253 254 static void commit_stack_push(struct commit_stack *stack, struct commit *commit) 255 {