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