Re: [PATCH 5/7] submodule: implement `module_list` as a builtin helper

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

 



On Wed, Aug 19, 2015 at 11:22 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Junio C Hamano <gitster@xxxxxxxxx> writes:
>
>> Micronit.  Even though multiplication is commutative, the order of
>> arguments to xcalloc() looks odd.  It lets you say "I want an array
>> with nmemb elements, and each of its is size-bytes long" by giving
>> it nmemb and then size.
>
> Unrelated tangent, but while I have output from "git grep 'calloc.*pathspec'"
> on my screen... ;-)
>
>  builtin/checkout.c | 2 +-
>  builtin/ls-files.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index 7ea533e..e3b28e4 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -283,7 +283,7 @@ static int checkout_paths(const struct checkout_opts *opts,
>         if (opts->source_tree)
>                 read_tree_some(opts->source_tree, &opts->pathspec);
>
> -       ps_matched = xcalloc(1, opts->pathspec.nr);
> +       ps_matched = xcalloc(opts->pathspec.nr, 1);
>
>         /*
>          * Make sure all pathspecs participated in locating the paths
> diff --git a/builtin/ls-files.c b/builtin/ls-files.c
> index 6fa2205..b6a7cb0 100644
> --- a/builtin/ls-files.c
> +++ b/builtin/ls-files.c
> @@ -516,7 +516,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
>
>         /* Treat unmatching pathspec elements as errors */
>         if (pathspec.nr && error_unmatch)
> -               ps_matched = xcalloc(1, pathspec.nr);
> +               ps_matched = xcalloc(pathspec.nr, 1);
>
>         if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given)
>                 die("ls-files --ignored needs some exclude pattern");

Looks good to me.
--
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]