[PATCH v3 01/10] trace2: introduce function to trace unsigned integers
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Aug 7, 2025, 08:04 UTC
- Message-ID
- <20250807-b4-pks-commit-graph-wo-the-repository-v3-1-82edef830a1e@pks.im>
- In-Reply-To
- <20250807-b4-pks-commit-graph-wo-the-repository-v3-0-82edef830a1e@pks.im>
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); +} + void trace2_data_json_fl(const char *file, int line, const char *category, const struct repository *repo, const char *key, const struct json_writer *value) diff --git a/trace2.h b/trace2.h index e4f23784e4..115c45a1eb 100644 --- a/trace2.h +++ b/trace2.h @@ -463,6 +463,15 @@ void trace2_data_intmax_fl(const char *file, int line, const char *category, trace2_data_intmax_fl(__FILE__, __LINE__, (category), (repo), (key), \ (value)) +void trace2_data_uintmax_fl(const char *file, int line, const char *category, + const struct repository *repo, const char *key, + uintmax_t value); + +#define trace2_data_uintmax(category, repo, key, value) \ + trace2_data_uintmax_fl(__FILE__, __LINE__, (category), (repo), (key), \ + (value)) + + void trace2_data_json_fl(const char *file, int line, const char *category, const struct repository *repo, const char *key, const struct json_writer *jw);
-- 2.51.0.rc0.215.g125493bb4a.dirty