Re: [PATCH 3/4] Teach builtin-add to pass multiple paths to git-add--interactive

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

 



On Thu, Nov 22, 2007 at 01:02:52AM +0100, Wincent Colaiuta wrote:

> -int interactive_add(const char *path)
> +int interactive_add(const char **argv, int argc)
>  {
> -	const char *argv[3] = { "add--interactive", path, NULL };
> -
> -	return run_command_v_opt(argv, RUN_GIT_CMD);
> +	int status;
> +	const char **args = xmalloc(sizeof(const char *) * (argc + 1));
> +	args[0] = "add--interactive";
> +	memcpy((void *)args + sizeof(const char *), argv, sizeof(const char *) * argc);

The source for the memcpy (argv) is sometimes NULL. The standard forbids
this, even when the size field is 0. I have no idea if any reasonable
implementations actually care.

But...

> +		if (argc > 0)
> +			exit(interactive_add(argv, argc));
>  		else
> -			exit(interactive_add(NULL));
> +			exit(interactive_add(NULL, 0));

There really is no reason to pass NULL at all (since the argc limits us
anyway), so we can just get rid of the conditional and simplify to:

  exit(interactive_add(argv, argc));

for both cases.

-Peff
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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