Re: [PATCH 6/6] t-reftable-stack: add test for stack iterators
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Aug 7, 2024, 05:23 UTC
- Message-ID
- <ZrME7SDUslFm4FqS@tanuki>
- In-Reply-To
- <20240806142020.4615-7-chandrapratap3519@gmail.com>
On Tue, Aug 06, 2024 at 07:43:42PM +0530, Chandra Pratap wrote:
> reftable_stack_init_ref_iterator and reftable_stack_init_log_iterator
> as defined by reftable/stack.{c, h} initialize a stack iterator toSame remark here that Junio posted on a preceding catch, please drop the space in `stack.{c,h}`.
Show 11 quoted lines
> @@ -521,6 +521,87 @@ static void t_reftable_stack_add(void)
> clear_dir(dir);
> }
>
> +static void t_reftable_stack_iterator(void)
> +{
> + struct reftable_write_options opts = { 0 };
> + struct reftable_stack *st = NULL;
> + char *dir = get_tmp_dir(__LINE__);
> + struct reftable_ref_record refs[10] = { { 0 } };
> + struct reftable_log_record logs[10] = { { 0 } };Again, these should be initialized with `= { 0 }`.Show 11 quoted lines
> + struct reftable_iterator it = { 0 };
> + size_t N = ARRAY_SIZE(refs), i;
> + int err;
> +
> + err = reftable_new_stack(&st, dir, &opts);
> + check(!err);
> +
> + for (i = 0; i < N; i++) {
> + char buf[20];
> + xsnprintf(buf, sizeof(buf), "branch%02"PRIuMAX, (uintmax_t)i);
> + refs[i].refname = xstrdup(buf);This can be simplified to a single call to `xstrfmt()`.
Patrick