git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chandra Pratap <chandrapratap3519@gmail.com>
To: git@vger.kernel.org
Cc: karthik.188@gmail.com, chriscool@tuxfamily.org
Subject: [PATCH v4 4/7] t-reftable-merged: improve the const-correctness of helper functions
Date: Fri, 12 Jul 2024 11:09:00 +0530	[thread overview]
Message-ID: <20240712055041.6476-5-chandrapratap3519@gmail.com> (raw)
In-Reply-To: <20240712055041.6476-1-chandrapratap3519@gmail.com>

In t-reftable-merged.c, a number of helper functions used by the
tests can be re-defined with parameters made 'const' which makes
it easier to understand if they're read-only or not. Re-define
these functions along these lines.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
---
 t/unit-tests/t-reftable-merged.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/t/unit-tests/t-reftable-merged.c b/t/unit-tests/t-reftable-merged.c
index f4c14c5d47..ff2f448bb6 100644
--- a/t/unit-tests/t-reftable-merged.c
+++ b/t/unit-tests/t-reftable-merged.c
@@ -15,7 +15,7 @@ license that can be found in the LICENSE file or at
 #include "reftable/reftable-merged.h"
 #include "reftable/reftable-writer.h"
 
-static ssize_t strbuf_add_void(void *b, const void *data, size_t sz)
+static ssize_t strbuf_add_void(void *b, const void *data, const size_t sz)
 {
 	strbuf_add(b, data, sz);
 	return sz;
@@ -27,7 +27,7 @@ static int noop_flush(void *arg)
 }
 
 static void write_test_table(struct strbuf *buf,
-			     struct reftable_ref_record refs[], size_t n)
+			     struct reftable_ref_record refs[], const size_t n)
 {
 	uint64_t min = 0xffffffff;
 	uint64_t max = 0;
@@ -62,9 +62,8 @@ static void write_test_table(struct strbuf *buf,
 	reftable_writer_free(w);
 }
 
-static void write_test_log_table(struct strbuf *buf,
-				 struct reftable_log_record logs[], size_t n,
-				 uint64_t update_index)
+static void write_test_log_table(struct strbuf *buf, struct reftable_log_record logs[],
+				 const size_t n, const uint64_t update_index)
 {
 	int err;
 
@@ -90,8 +89,8 @@ static void write_test_log_table(struct strbuf *buf,
 static struct reftable_merged_table *
 merged_table_from_records(struct reftable_ref_record **refs,
 			  struct reftable_block_source **source,
-			  struct reftable_reader ***readers, size_t *sizes,
-			  struct strbuf *buf, size_t n)
+			  struct reftable_reader ***readers, const size_t *sizes,
+			  struct strbuf *buf, const size_t n)
 {
 	struct reftable_merged_table *mt = NULL;
 	struct reftable_table *tabs;
@@ -116,7 +115,7 @@ merged_table_from_records(struct reftable_ref_record **refs,
 	return mt;
 }
 
-static void readers_destroy(struct reftable_reader **readers, size_t n)
+static void readers_destroy(struct reftable_reader **readers, const size_t n)
 {
 	for (size_t i = 0; i < n; i++)
 		reftable_reader_free(readers[i]);
@@ -267,8 +266,8 @@ static void t_merged_refs(void)
 static struct reftable_merged_table *
 merged_table_from_log_records(struct reftable_log_record **logs,
 			      struct reftable_block_source **source,
-			      struct reftable_reader ***readers, size_t *sizes,
-			      struct strbuf *buf, size_t n)
+			      struct reftable_reader ***readers, const size_t *sizes,
+			      struct strbuf *buf, const size_t n)
 {
 	struct reftable_merged_table *mt = NULL;
 	struct reftable_table *tabs;
-- 
2.45.GIT


  parent reply	other threads:[~2024-07-12  5:51 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03 17:01 [GSoC][PATCH 0/5] t: port reftable/merged_test.c to the unit testing framework Chandra Pratap
2024-07-03 17:01 ` [PATCH 1/5] t: move " Chandra Pratap
2024-07-05 17:40   ` Karthik Nayak
2024-07-06  7:13     ` Chandra Pratap
2024-07-03 17:01 ` [PATCH 2/5] t: harmonize t-reftable-merged.c with coding guidelines Chandra Pratap
2024-07-05 18:08   ` Karthik Nayak
2024-07-03 17:01 ` [PATCH 3/5] t-reftable-merged: add tests for reftable_merged_table_max_update_index Chandra Pratap
2024-07-03 17:01 ` [PATCH 4/5] t-reftable-merged: use reftable_ref_record_equal to compare ref records Chandra Pratap
2024-07-05 18:14   ` Karthik Nayak
2024-07-03 17:01 ` [PATCH 5/5] t-reftable-merged: add test for REFTABLE_FORMAT_ERROR Chandra Pratap
2024-07-05 18:24 ` [GSoC][PATCH 0/5] t: port reftable/merged_test.c to the unit testing framework Karthik Nayak
2024-07-09  5:28 ` [GSoC][PATCH v2 0/7] " Chandra Pratap
2024-07-09  5:28   ` [PATCH v2 1/7] t: move " Chandra Pratap
2024-07-09 23:05     ` Justin Tobler
2024-07-09  5:28   ` [PATCH v2 2/7] t: harmonize t-reftable-merged.c with coding guidelines Chandra Pratap
2024-07-09  5:28   ` [PATCH v2 3/7] t-reftable-merged: improve the test t_merged_single_record() Chandra Pratap
2024-07-09  5:28   ` [PATCH v2 4/7] t-reftable-merged: improve the const-correctness of helper functions Chandra Pratap
2024-07-09  5:28   ` [PATCH v2 5/7] t-reftable-merged: add tests for reftable_merged_table_max_update_index Chandra Pratap
2024-07-09  5:28   ` [PATCH v2 6/7] t-reftable-merged: use reftable_ref_record_equal to compare ref records Chandra Pratap
2024-07-09  5:28   ` [PATCH v2 7/7] t-reftable-merged: add test for REFTABLE_FORMAT_ERROR Chandra Pratap
2024-07-10  9:18     ` Karthik Nayak
2024-07-10  9:19   ` [GSoC][PATCH v2 0/7] t: port reftable/merged_test.c to the unit testing framework Karthik Nayak
2024-07-11 14:38     ` Junio C Hamano
2024-07-11  3:58   ` [GSoC][PATCH v3 " Chandra Pratap
2024-07-11  3:58     ` [PATCH v3 1/7] t: move " Chandra Pratap
2024-07-11  3:58     ` [PATCH v3 2/7] t: harmonize t-reftable-merged.c with coding guidelines Chandra Pratap
2024-07-11 20:38       ` Junio C Hamano
2024-07-11  3:58     ` [PATCH v3 3/7] t-reftable-merged: improve the test t_merged_single_record() Chandra Pratap
2024-07-11  3:58     ` [PATCH v3 4/7] t-reftable-merged: improve the const-correctness of helper functions Chandra Pratap
2024-07-11  3:58     ` [PATCH v3 5/7] t-reftable-merged: add tests for reftable_merged_table_max_update_index Chandra Pratap
2024-07-11  3:58     ` [PATCH v3 6/7] t-reftable-merged: use reftable_ref_record_equal to compare ref records Chandra Pratap
2024-07-11  3:58     ` [PATCH v3 7/7] t-reftable-merged: add test for REFTABLE_FORMAT_ERROR Chandra Pratap
2024-07-12  5:38     ` [GSoC][PATCH v4 0/7] t: port reftable/merged_test.c to the unit testing framework Chandra Pratap
2024-07-12  5:38       ` [PATCH v4 1/7] t: move " Chandra Pratap
2024-07-12  5:38       ` [PATCH v4 2/7] t: harmonize t-reftable-merged.c with coding guidelines Chandra Pratap
2024-07-12  5:38       ` [PATCH v4 3/7] t-reftable-merged: improve the test t_merged_single_record() Chandra Pratap
2024-07-12  5:39       ` Chandra Pratap [this message]
2024-07-24  9:12         ` [PATCH v4 4/7] t-reftable-merged: improve the const-correctness of helper functions Patrick Steinhardt
2024-07-12  5:39       ` [PATCH v4 5/7] t-reftable-merged: add tests for reftable_merged_table_max_update_index Chandra Pratap
2024-07-12  5:39       ` [PATCH v4 6/7] t-reftable-merged: use reftable_ref_record_equal to compare ref records Chandra Pratap
2024-07-12  5:39       ` [PATCH v4 7/7] t-reftable-merged: add test for REFTABLE_FORMAT_ERROR Chandra Pratap

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=20240712055041.6476-5-chandrapratap3519@gmail.com \
    --to=chandrapratap3519@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=karthik.188@gmail.com \
    /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).