Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-09-27 15:58:41 +0300
committerJunio C Hamano <gitster@pobox.com>2021-09-28 01:02:32 +0300
commit6e54a32468e209aa724b37496fcc63f4ebe84f60 (patch)
tree8820ae3a54e35f24c0a59c9ad6184af591414e77 /daemon.c
parenta30321b9eaede5a1d639936d212e2d0fc8d414c8 (diff)
daemon.c: refactor hostinfo_init() to HOSTINFO_INIT macro
Remove the hostinfo_init() function added in 01cec54e135 (daemon: deglobalize hostname information, 2015-03-07) and instead initialize the "struct hostinfo" with a macro. This is the more idiomatic pattern in the codebase, and doesn't leave us wondering when we see the *_init() function if this struct needs more complex initialization than a macro can provide. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'daemon.c')
-rw-r--r--daemon.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/daemon.c b/daemon.c
index 5c4cbad62d..d80d009d1a 100644
--- a/daemon.c
+++ b/daemon.c
@@ -63,6 +63,12 @@ struct hostinfo {
unsigned int hostname_lookup_done:1;
unsigned int saw_extended_args:1;
};
+#define HOSTINFO_INIT { \
+ .hostname = STRBUF_INIT, \
+ .canon_hostname = STRBUF_INIT, \
+ .ip_address = STRBUF_INIT, \
+ .tcp_port = STRBUF_INIT, \
+}
static void lookup_hostname(struct hostinfo *hi);
@@ -727,15 +733,6 @@ static void lookup_hostname(struct hostinfo *hi)
}
}
-static void hostinfo_init(struct hostinfo *hi)
-{
- memset(hi, 0, sizeof(*hi));
- strbuf_init(&hi->hostname, 0);
- strbuf_init(&hi->canon_hostname, 0);
- strbuf_init(&hi->ip_address, 0);
- strbuf_init(&hi->tcp_port, 0);
-}
-
static void hostinfo_clear(struct hostinfo *hi)
{
strbuf_release(&hi->hostname);
@@ -760,11 +757,9 @@ static int execute(void)
char *line = packet_buffer;
int pktlen, len, i;
char *addr = getenv("REMOTE_ADDR"), *port = getenv("REMOTE_PORT");
- struct hostinfo hi;
+ struct hostinfo hi = HOSTINFO_INIT;
struct strvec env = STRVEC_INIT;
- hostinfo_init(&hi);
-
if (addr)
loginfo("Connection from %s:%s", addr, port);