urlmatch.[ch]: add and use URLMATCH_CONFIG_INIT
Change the initialization pattern of "struct urlmatch_config" to use an *_INIT macro and designated initializers. Right now there's no other "struct" member of "struct urlmatch_config" which would require its own *_INIT, but it's good practice not to assume that. Let's also change this to a designated initializer while we're at it. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Oct 1, 2021 at 12:27 UTC
73ee449bbf2918e29d26361e57f35a24f224e3be
4 files changed
+7
-3
builtin/config.c
+1
-1
@@ -575,7 +575,7 @@ static int get_urlmatch(const char *var, const char *url)
575
int ret;
576
char *section_tail;
577
struct string_list_item *item;
578
- struct urlmatch_config config = { STRING_LIST_INIT_DUP };
578
+ struct urlmatch_config config = URLMATCH_CONFIG_INIT;
579
struct string_list values = STRING_LIST_INIT_DUP;
580
581
config.collect_fn = urlmatch_collect_fn;
credential.c
+1
-1
@@ -105,7 +105,7 @@ static int match_partial_url(const char *url, void *cb)
105
static void credential_apply_config(struct credential *c)
106
{
107
char *normalized_url;
108
- struct urlmatch_config config = { STRING_LIST_INIT_DUP };
108
+ struct urlmatch_config config = URLMATCH_CONFIG_INIT;
109
struct strbuf url = STRBUF_INIT;
110
111
if (!c->host)
http.c
+1
-1
@@ -990,7 +990,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
990
char *low_speed_limit;
991
char *low_speed_time;
992
char *normalized_url;
993
- struct urlmatch_config config = { STRING_LIST_INIT_DUP };
993
+ struct urlmatch_config config = URLMATCH_CONFIG_INIT;
994
995
config.section = "http";
996
config.key = NULL;
urlmatch.h
+4
@@ -66,6 +66,10 @@ struct urlmatch_config {
66
int (*fallback_match_fn)(const char *url, void *cb);
67
};
68
69
+#define URLMATCH_CONFIG_INIT { \
70
+ .vars = STRING_LIST_INIT_DUP, \
71
+}
72
+
73
int urlmatch_config_entry(const char *var, const char *value, void *cb);
74
75
#endif /* URL_MATCH_H */