From: Chandra Pratap <chandrapratap3519@gmail.com>
To: git@vger.kernel.org
Cc: Chandra Pratap <chandrapratap3519@gmail.com>
Subject: [PATCH] unit-tests: use xstrfmt() instead of a char buffer in t-reftable-stack
Date: Tue, 1 Oct 2024 22:35:55 +0530 [thread overview]
Message-ID: <20241001170629.7768-1-chandrapratap3519@gmail.com> (raw)
A char buffer is used to hold refname values as formatted strings
in the reftable_stack_add() test in t/unit-tests/t-reftable-stack.c.
This can be replaced with a single call to xstrfmt() making the test
conciser.
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
---
t/unit-tests/t-reftable-stack.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/t/unit-tests/t-reftable-stack.c b/t/unit-tests/t-reftable-stack.c
index 31d563d992..2d7cfbf8aa 100644
--- a/t/unit-tests/t-reftable-stack.c
+++ b/t/unit-tests/t-reftable-stack.c
@@ -523,14 +523,12 @@ static void t_reftable_stack_add(void)
check(!err);
for (i = 0; i < N; i++) {
- char buf[256];
- snprintf(buf, sizeof(buf), "branch%02"PRIuMAX, (uintmax_t)i);
- refs[i].refname = xstrdup(buf);
+ refs[i].refname = xstrfmt("branch%02"PRIuMAX, (uintmax_t)i);
refs[i].update_index = i + 1;
refs[i].value_type = REFTABLE_REF_VAL1;
t_reftable_set_hash(refs[i].value.val1, i, GIT_SHA1_FORMAT_ID);
- logs[i].refname = xstrdup(buf);
+ logs[i].refname = xstrfmt("branch%02"PRIuMAX, (uintmax_t)i);
logs[i].update_index = N + i + 1;
logs[i].value_type = REFTABLE_LOG_UPDATE;
logs[i].value.update.email = xstrdup("identity@invalid");
--
2.45.GIT
next reply other threads:[~2024-10-01 17:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-01 17:05 Chandra Pratap [this message]
2024-10-01 19:22 ` [PATCH] unit-tests: use xstrfmt() instead of a char buffer in t-reftable-stack Junio C Hamano
2024-10-01 19:32 ` Eric Sunshine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241001170629.7768-1-chandrapratap3519@gmail.com \
--to=chandrapratap3519@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).