git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 04/13] run-command: make `exists_in_PATH()` non-static

From
Taylor Blau <me@ttaylorr.com>
Date
Feb 9, 2020, 23:16 UTC
Message-ID
<20200209231602.GC4530@syl.local>
In-Reply-To
<20200208090704.26506-5-mirucam@gmail.com>
On Sat, Feb 08, 2020 at 10:06:55AM +0100, Miriam Rubio wrote:
Show 6 quoted lines
> From: Pranit Bauva <pranit.bauva@gmail.com>
>
> Removes the `static` keyword from `exists_in_PATH()` function
> and declares the function in `run-command.h` file.
> The function will be used in bisect_visualize() in a later
> commit.
There may be some odd line-wrapping going on here.
Show 41 quoted lines
> `exists_in_PATH()` and `locate_in_PATH()` functions don't
> depend on file-local variables.
>
> Mentored by: Christian Couder <chriscool@tuxfamily.org>
> Mentored by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
> Signed-off-by: Miriam Rubio <mirucam@gmail.com>
> ---
>  run-command.c |  2 +-
>  run-command.h | 11 +++++++++++
>  2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/run-command.c b/run-command.c
> index f5e1149f9b..4df975178d 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -210,7 +210,7 @@ static char *locate_in_PATH(const char *file)
>  	return NULL;
>  }
>
> -static int exists_in_PATH(const char *file)
> +int exists_in_PATH(const char *file)
>  {
>  	char *r = locate_in_PATH(file);
>  	int found = r != NULL;
> diff --git a/run-command.h b/run-command.h
> index 592d9dc035..7c8e206d97 100644
> --- a/run-command.h
> +++ b/run-command.h
> @@ -172,6 +172,17 @@ void child_process_clear(struct child_process *);
>
>  int is_executable(const char *name);
>
> +/**
> + * Returns if a $PATH given by parameter is found or not (it is NULL). This
> + * function uses locate_in_PATH() function that emulates the path search that
> + * execvp would perform. Memory used to store the resultant path is freed by
> + * the function.
> + *
> + * The caller should ensure that $PATH contains no directory
> + * separators.

This line-wrapping caught my eye: it looks like 'separators' would fit on the line before, or at least that this paragraph and the one above it are wrapped at two different widths.

I'm not sure that it really matters, since it looks like the wrapping in this file isn't entirely consistent, but I figured that I'd point it out nonetheless.

> + */
> +int exists_in_PATH(const char *);

Have you considered naming this argument? It's somewhat clear from the documentation, but I don't see a reason not to name it (especially since other declarations in this file *do* name their parameters). What about:

  int exists_in_PATH(const char *file);

To match its definition in 'run-command.c'? (Admittedly, if I had written this I'd probably call it 'entry', but they should at least be consistent).

Show 7 quoted lines
> +
>  /**
>   * Start a sub-process. Takes a pointer to a `struct child_process`
>   * that specifies the details and returns pipe FDs (if requested).
> --
> 2.25.0
>

Thanks, Taylor

Previous: Miriam R.Next: Miriam Rubio
Message 8 of 18 in “Finish converting git bisect to C part 1”
  1. Miriam RubioFeb 8, 2020
  2. 01/13 bisect--helper: convert `vocab_*` char pointers to char arraysMiriam Rubio, Feb 8, 2020
  3. 02/13 bisect--helper: change `retval` to `res`Miriam Rubio, Feb 8, 2020
  4. 03/13 bisect: use the standard 'if (!var)' way to check for 0Miriam Rubio, Feb 8, 2020
  5. 04/13 run-command: make `exists_in_PATH()` non-staticMiriam Rubio, Feb 8, 2020
  6. René ScharfeFeb 8, 2020
  7. Miriam R.Feb 9, 2020
  8. Taylor BlauFeb 9, 2020
  9. 06/13 bisect: add enum to represent bisect returning codesMiriam Rubio, Feb 8, 2020
  10. 05/13 bisect--helper: introduce new `decide_next()` functionMiriam Rubio, Feb 8, 2020
  11. 07/13 bisect--helper: return error codes from `cmd_bisect__helper()`Miriam Rubio, Feb 8, 2020
  12. 08/13 bisect: libify `exit_if_skipped_commits` to `error_if_skipped*` and its dependentsMiriam Rubio, Feb 8, 2020
  13. 09/13 bisect: libify `bisect_checkout`Miriam Rubio, Feb 8, 2020
  14. 10/13 bisect: libify `check_merge_bases` and its dependentsMiriam Rubio, Feb 8, 2020
  15. 12/13 bisect: libify `handle_bad_merge_base` and its dependentsMiriam Rubio, Feb 8, 2020
  16. 11/13 bisect: libify `check_good_are_ancestors_of_bad` and its dependentsMiriam Rubio, Feb 8, 2020
  17. 13/13 bisect: libify `bisect_next_all`Miriam Rubio, Feb 8, 2020
  18. Miriam R.Feb 10, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.