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

Re: [PATCH v1 1/1] trace2: NULL is not allowed for va_list

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 18, 2019, 06:18 UTC
Message-ID
<xmqqlg1c3dtq.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190316104715.27138-1-tboegi@web.de>
tboegi@web.de writes:
> From: Torsten Bögershausen <tboegi@web.de>
>
> Some compilers don't allow NULL to be passed for a va_list.
> Use va_list instead.
Wow (I seem to be keep saying this today).
Show 110 quoted lines
>
> Signed-off-by: Torsten Bögershausen <tboegi@web.de>
> ---
>  trace2.c                | 15 +++++++++++----
>  trace2.h                |  4 ++--
>  trace2/tr2_tgt_event.c  |  2 +-
>  trace2/tr2_tgt_normal.c |  2 +-
>  trace2/tr2_tgt_perf.c   |  2 +-
>  5 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/trace2.c b/trace2.c
> index ccccd4ef09..8bbad56887 100644
> --- a/trace2.c
> +++ b/trace2.c
> @@ -548,10 +548,14 @@ void trace2_region_enter_printf_va_fl(const char *file, int line,
>  }
>
>  void trace2_region_enter_fl(const char *file, int line, const char *category,
> -			    const char *label, const struct repository *repo)
> +			    const char *label, const struct repository *repo, ...)
>  {
> +	va_list ap;
> +	va_start(ap, repo);
>  	trace2_region_enter_printf_va_fl(file, line, category, label, repo,
> -					 NULL, NULL);
> +					 NULL, ap);
> +	va_end(ap);
> +
>  }
>
>  void trace2_region_enter_printf_fl(const char *file, int line,
> @@ -621,10 +625,13 @@ void trace2_region_leave_printf_va_fl(const char *file, int line,
>  }
>
>  void trace2_region_leave_fl(const char *file, int line, const char *category,
> -			    const char *label, const struct repository *repo)
> +			    const char *label, const struct repository *repo, ...)
>  {
> +	va_list ap;
> +	va_start(ap, repo);
>  	trace2_region_leave_printf_va_fl(file, line, category, label, repo,
> -					 NULL, NULL);
> +					 NULL, ap);
> +	va_end(ap);
>  }
>
>  void trace2_region_leave_printf_fl(const char *file, int line,
> diff --git a/trace2.h b/trace2.h
> index ae5020d0e6..b330a54a89 100644
> --- a/trace2.h
> +++ b/trace2.h
> @@ -238,7 +238,7 @@ void trace2_def_repo_fl(const char *file, int line, struct repository *repo);
>   * on this thread.
>   */
>  void trace2_region_enter_fl(const char *file, int line, const char *category,
> -			    const char *label, const struct repository *repo);
> +			    const char *label, const struct repository *repo, ...);
>
>  #define trace2_region_enter(category, label, repo) \
>  	trace2_region_enter_fl(__FILE__, __LINE__, (category), (label), (repo))
> @@ -278,7 +278,7 @@ void trace2_region_enter_printf(const char *category, const char *label,
>   * in this nesting level.
>   */
>  void trace2_region_leave_fl(const char *file, int line, const char *category,
> -			    const char *label, const struct repository *repo);
> +			    const char *label, const struct repository *repo, ...);
>
>  #define trace2_region_leave(category, label, repo) \
>  	trace2_region_leave_fl(__FILE__, __LINE__, (category), (label), (repo))
> diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c
> index 107cb5317d..1cf4f62441 100644
> --- a/trace2/tr2_tgt_event.c
> +++ b/trace2/tr2_tgt_event.c
> @@ -190,7 +190,7 @@ static void fn_atexit(uint64_t us_elapsed_absolute, int code)
>  static void maybe_add_string_va(struct json_writer *jw, const char *field_name,
>  				const char *fmt, va_list ap)
>  {
> -	if (fmt && *fmt && ap) {
> +	if (fmt && *fmt) {
>  		va_list copy_ap;
>  		struct strbuf buf = STRBUF_INIT;
>
> diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c
> index 547183d5b6..1a07d70abd 100644
> --- a/trace2/tr2_tgt_normal.c
> +++ b/trace2/tr2_tgt_normal.c
> @@ -126,7 +126,7 @@ static void fn_atexit(uint64_t us_elapsed_absolute, int code)
>  static void maybe_append_string_va(struct strbuf *buf, const char *fmt,
>  				   va_list ap)
>  {
> -	if (fmt && *fmt && ap) {
> +	if (fmt && *fmt) {
>  		va_list copy_ap;
>
>  		va_copy(copy_ap, ap);
> diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
> index f0746fcf86..2a866d701b 100644
> --- a/trace2/tr2_tgt_perf.c
> +++ b/trace2/tr2_tgt_perf.c
> @@ -211,7 +211,7 @@ static void fn_atexit(uint64_t us_elapsed_absolute, int code)
>  static void maybe_append_string_va(struct strbuf *buf, const char *fmt,
>  				   va_list ap)
>  {
> -	if (fmt && *fmt && ap) {
> +	if (fmt && *fmt) {
>  		va_list copy_ap;
>
>  		va_copy(copy_ap, ap);
> --
> 2.21.0.135.g6e0cc67761
Previous: tboegi@web.deNext: Jeff Hostetler
Message 2 of 5 in “trace2: NULL is not allowed for va_list”
  1. 1/1 trace2: NULL is not allowed for va_listtboegi@web.de, Mar 16, 2019
  2. Junio C HamanoMar 18, 2019
  3. Jeff HostetlerMar 18, 2019
  4. Torsten BögershausenMar 18, 2019
  5. Morten WelinderMar 18, 2019

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.