Re: [PATCH 6/6] t-reftable-stack: add test for stack iterators

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 to

Same remark here that Junio posted on a preceding catch, please drop the
space in `stack.{c,h}`.

> @@ -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 }`.

> +	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

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux