Re: [PATCH 1/9] trace2: introduce function to trace unsigned integers
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Aug 4, 2025, 21:33 UTC
- Message-ID
- <aJEnM0IOrgwizw2Y@nand.local>
- In-Reply-To
- <20250804-b4-pks-commit-graph-wo-the-repository-v1-1-850d626eb2e8@pks.im>
On Mon, Aug 04, 2025 at 10:17:17AM +0200, Patrick Steinhardt wrote:
Show 34 quoted lines
> While we have `trace2_data_intmax()`, there is no equivalent function
> that takes an unsigned integer. Introduce `trace2_data_uintmax()` to
> plug this gap.
>
> This function will be used in a subsequent commit.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> trace2.c | 14 ++++++++++++++
> trace2.h | 9 +++++++++
> 2 files changed, 23 insertions(+)
>
> diff --git a/trace2.c b/trace2.c
> index c23c0a227b..a687944f7b 100644
> --- a/trace2.c
> +++ b/trace2.c
> @@ -948,6 +948,20 @@ void trace2_data_intmax_fl(const char *file, int line, const char *category,
> strbuf_release(&buf_string);
> }
>
> +void trace2_data_uintmax_fl(const char *file, int line, const char *category,
> + const struct repository *repo, const char *key,
> + uintmax_t value)
> +{
> + struct strbuf buf_string = STRBUF_INIT;
> +
> + if (!trace2_enabled)
> + return;
> +
> + strbuf_addf(&buf_string, "%" PRIuMAX, value);
> + trace2_data_string_fl(file, line, category, repo, key, buf_string.buf);
> + strbuf_release(&buf_string);
> +}
> +Looks like a faithful copy of its signed counterpart above, which is good. We *could* use a macro for this, but I don't think we *should* ;-).
Thanks, Taylor