[PATCH v2 3/5] urlmatch.[ch]: add and use URLMATCH_CONFIG_INIT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Change the initialization pattern of "struct urlmatch_config" to use
an *_INIT macro and designated initializers.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 builtin/config.c | 3 +--
 credential.c     | 4 +---
 http.c           | 4 +---
 urlmatch.h       | 4 ++++
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/builtin/config.c b/builtin/config.c
index 865fddd6ce8..1ea4f68b7de 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -575,11 +575,10 @@ static int get_urlmatch(const char *var, const char *url)
 	int ret;
 	char *section_tail;
 	struct string_list_item *item;
-	struct urlmatch_config config = { STRING_LIST_INIT_DUP };
+	struct urlmatch_config config = URLMATCH_CONFIG_INIT;
 	struct string_list values = STRING_LIST_INIT_DUP;
 
 	config.collect_fn = urlmatch_collect_fn;
-	config.cascade_fn = NULL;
 	config.cb = &values;
 
 	if (!url_normalize(url, &config.url))
diff --git a/credential.c b/credential.c
index 000ac7a8d43..c85db8a75cd 100644
--- a/credential.c
+++ b/credential.c
@@ -105,7 +105,7 @@ static int match_partial_url(const char *url, void *cb)
 static void credential_apply_config(struct credential *c)
 {
 	char *normalized_url;
-	struct urlmatch_config config = { STRING_LIST_INIT_DUP };
+	struct urlmatch_config config = URLMATCH_CONFIG_INIT;
 	struct strbuf url = STRBUF_INIT;
 
 	if (!c->host)
@@ -117,9 +117,7 @@ static void credential_apply_config(struct credential *c)
 		return;
 
 	config.section = "credential";
-	config.key = NULL;
 	config.collect_fn = credential_config_callback;
-	config.cascade_fn = NULL;
 	config.select_fn = select_all;
 	config.fallback_match_fn = match_partial_url;
 	config.cb = c;
diff --git a/http.c b/http.c
index d7c20493d7f..3d6ad5c7be8 100644
--- a/http.c
+++ b/http.c
@@ -990,13 +990,11 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
 	char *low_speed_limit;
 	char *low_speed_time;
 	char *normalized_url;
-	struct urlmatch_config config = { STRING_LIST_INIT_DUP };
+	struct urlmatch_config config = URLMATCH_CONFIG_INIT;
 
 	config.section = "http";
-	config.key = NULL;
 	config.collect_fn = http_options;
 	config.cascade_fn = git_default_config;
-	config.cb = NULL;
 
 	http_is_verbose = 0;
 	normalized_url = url_normalize(url, &config.url);
diff --git a/urlmatch.h b/urlmatch.h
index 6ff42f81b0c..34a3ba6d197 100644
--- a/urlmatch.h
+++ b/urlmatch.h
@@ -66,6 +66,10 @@ struct urlmatch_config {
 	int (*fallback_match_fn)(const char *url, void *cb);
 };
 
+#define URLMATCH_CONFIG_INIT { \
+	.vars = STRING_LIST_INIT_DUP, \
+}
+
 int urlmatch_config_entry(const char *var, const char *value, void *cb);
 
 #endif /* URL_MATCH_H */
-- 
2.33.0.1316.gb2e9b3ba3ae




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux