From: "René Scharfe" <l.s.r@web.de>
To: Jeff King <peff@peff.net>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] daemon: use strbuf for hostname info
Date: Sat, 07 Mar 2015 01:20:22 +0100 [thread overview]
Message-ID: <54FA4446.5050103@web.de> (raw)
In-Reply-To: <20150306210627.GA24267@peff.net>
Am 06.03.2015 um 22:06 schrieb Jeff King:
> On Fri, Mar 06, 2015 at 09:57:22AM +0100, René Scharfe wrote:
>
>> Convert hostname, canon_hostname, ip_address and tcp_port to strbuf.
>> This allows to get rid of the helpers strbuf_addstr_or_null() and STRARG
>> because a strbuf always represents a valid (initially empty) string.
>> sanitize_client() becomes unused and is removed as well.
>
> Makes sense. I had a feeling that we might have cared about NULL versus
> the empty string somewhere, but I did not see it in the patch below, so
> I think it is fine.
>
>> -static char *sanitize_client(const char *in)
>> -{
>> - struct strbuf out = STRBUF_INIT;
>> - sanitize_client_strbuf(&out, in);
>> - return strbuf_detach(&out, NULL);
>> -}
>
> Not a big deal, but do we want to rename sanitize_client_strbuf to
> sanitize_client? It only had the unwieldy name to distinguish it from
> this one.
A patch would look like this. The result is shorter, but no win in
terms of vertical space (number of lines).
-- >8 --
Subject: daemon: drop _strbuf suffix of sanitize and canonicalize functions
Now that only the strbuf variants of the functions remain, remove the
"_strbuf" part from their names.
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
daemon.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/daemon.c b/daemon.c
index c04315e..0412f8c 100644
--- a/daemon.c
+++ b/daemon.c
@@ -534,7 +534,7 @@ static void parse_host_and_port(char *hostport, char **host,
* trailing and leading dots, which means that the client cannot escape
* our base path via ".." traversal.
*/
-static void sanitize_client_strbuf(struct strbuf *out, const char *in)
+static void sanitize_client(struct strbuf *out, const char *in)
{
for (; *in; in++) {
if (*in == '/')
@@ -549,12 +549,12 @@ static void sanitize_client_strbuf(struct strbuf *out, const char *in)
}
/*
- * Like sanitize_client_strbuf, but we also perform any canonicalization
+ * Like sanitize_client, but we also perform any canonicalization
* to make life easier on the admin.
*/
-static void canonicalize_client_strbuf(struct strbuf *out, const char *in)
+static void canonicalize_client(struct strbuf *out, const char *in)
{
- sanitize_client_strbuf(out, in);
+ sanitize_client(out, in);
strbuf_tolower(out);
}
@@ -579,10 +579,10 @@ static void parse_host_arg(char *extra_args, int buflen)
parse_host_and_port(val, &host, &port);
if (port) {
strbuf_reset(&tcp_port);
- sanitize_client_strbuf(&tcp_port, port);
+ sanitize_client(&tcp_port, port);
}
strbuf_reset(&hostname);
- canonicalize_client_strbuf(&hostname, host);
+ canonicalize_client(&hostname, host);
hostname_lookup_done = 0;
}
@@ -620,8 +620,8 @@ static void lookup_hostname(void)
strbuf_reset(&canon_hostname);
if (ai->ai_canonname)
- sanitize_client_strbuf(&canon_hostname,
- ai->ai_canonname);
+ sanitize_client(&canon_hostname,
+ ai->ai_canonname);
else
strbuf_addbuf(&canon_hostname, &ip_address);
@@ -645,7 +645,7 @@ static void lookup_hostname(void)
addrbuf, sizeof(addrbuf));
strbuf_reset(&canon_hostname);
- sanitize_client_strbuf(&canon_hostname, hent->h_name);
+ sanitize_client(&canon_hostname, hent->h_name);
strbuf_reset(&ip_address);
strbuf_addstr(&ip_address, addrbuf);
}
--
2.3.1
next prev parent reply other threads:[~2015-03-07 0:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-06 8:57 [PATCH] daemon: use strbuf for hostname info René Scharfe
2015-03-06 21:06 ` Jeff King
2015-03-07 0:20 ` René Scharfe [this message]
2015-03-07 1:08 ` Jeff King
2015-03-07 10:49 ` René Scharfe
2015-03-07 0:54 ` René Scharfe
2015-03-07 1:07 ` Jeff King
2015-03-07 10:50 ` [PATCH v2 1/2] " René Scharfe
2015-03-07 10:50 ` [PATCH v2 2/2] daemon: deglobalize hostname information René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54FA4446.5050103@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.