git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
Cc: git@vger.kernel.org
Subject: Re: [RFC PATCH v6 3/3] git-remote-ext
Date: Fri, 8 Oct 2010 17:02:20 -0500	[thread overview]
Message-ID: <20101008220220.GA15214@burratino> (raw)
In-Reply-To: <1286571713-7755-4-git-send-email-ilari.liusvaara@elisanet.fi>

Ilari Liusvaara wrote:

> Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>

Just a few random nits.

> +++ b/builtin/remote-ext.c
> @@ -0,0 +1,243 @@
[...]
[...]
> +			default:
> +				die("Bad remote-ext placeholder '\\%c'.",
> +					str[rpos]);

Should be "Bad remote-ext placeholder '%%%c'.", I think.

> +static const char **parse_argv(const char *arg, const char *service)
> +{
> +	int arguments = 0;
> +	int i;
> +	char **ret;
> +	char *(temparray[MAXARGUMENTS + 1]);

Would be more idiomatic to leave out the parentheses.

> +
> +	while (*arg) {
> +		char *ret;

Would be clearer without shadowing.  Maybe

		char *expanded;

[...]
> +	ret = xcalloc(arguments + 1, sizeof(char *));
> +	for (i = 0; i < arguments; i++)
> +		ret[i] = temparray[i];
> +
> +	return (const char **)ret;

Maybe


	ret = xmalloc(...
	for (...

	ret[arguments] = NULL;
	return ret;

(to avoid clearing memory that is about to be overwritten) or even

	ret = xmalloc(...
	memcpy(ret, temparray, arguments * sizeof(*ret));
	ret[arguments] = NULL;
	return ret;

(to emphasize the copy) would make sense?

Why is ret of type char ** and then cast away rather than being
const char ** in the first place?

> +static int command_loop(const char *child)
> +{
> +	char buffer[MAXCOMMAND];
> +
> +	while (1) {
> +		if (!fgets(buffer, MAXCOMMAND - 1, stdin))
> +			exit(0);

Won't this exit(0) for I/O errors?

> +		/* Strip end of line characters. */
> +		while (isspace((unsigned char)buffer[strlen(buffer) - 1]))
> +			buffer[strlen(buffer) - 1] = 0;

This is wasteful: strlen() has to look for the null byte three times
just to strip a \r\n from the end.  See remote-fd for an example of
how to avoid that overhead.

      reply	other threads:[~2010-10-08 22:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-08 21:01 [RFC PATCH v6 0/3] git-remote-fd & git-remote-ext Ilari Liusvaara
2010-10-08 21:01 ` [RFC PATCH v6 1/3] Add bidirectional_transfer_loop() Ilari Liusvaara
2010-10-12  3:57   ` Junio C Hamano
2010-10-08 21:01 ` [RFC PATCH v6 2/3] git-remote-fd Ilari Liusvaara
2010-10-08 21:01 ` [RFC PATCH v6 3/3] git-remote-ext Ilari Liusvaara
2010-10-08 22:02   ` Jonathan Nieder [this message]

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=20101008220220.GA15214@burratino \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=ilari.liusvaara@elisanet.fi \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).