Re: [PATCH v14 04/16] Refactor quote_path_relative, remove unused params
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 24, 2013, 19:15 UTC
- Message-ID
- <7vd2rb8gmc.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <c7b9df81fad6a5b87400ae7beb6e6c2b7d48a67b.1372087065.git.worldhello.net@gmail.com>
Jiang Xin <worldhello.net@gmail.com> writes:
Show 16 quoted lines
> After substitute path_relative() in quote.c with relative_path() from
> path.c, parameters (such as len and prefix_len) are obsolete in function
> quote_path_relative(). Remove unused parameters and change the order of
> parameters for quote_path_relative() function.
> ...
> diff --git a/builtin/clean.c b/builtin/clean.c
> index 04e39..f77f95 100644
> --- a/builtin/clean.c
> +++ b/builtin/clean.c
> @@ -262,7 +262,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix)
> if (remove_dirs(&directory, prefix, rm_flags, dry_run, quiet, &gone))
> errors++;
> if (gone && !quiet) {
> - qname = quote_path_relative(directory.buf, directory.len, &buf, prefix);
> + qname = quote_path_relative(directory.buf, prefix, &buf);
> printf(dry_run ? _(msg_would_remove) : _(msg_remove), qname);This one needed a bit closer look to make sure directory.len is already pointing at the end of directory.buf (it is) to verify that this is a safe conversion. Everywhere else we lost either -1 or strlen() of the string we feed quote_path() and quote_path_relative() so they look fine.