diff mbox series

[03/10] reftable/reader: rename `reftable_new_reader()`

Message ID e658b372f046616779cf49c6c9346a49c2ce1485.1724080006.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series reftable: fix reload with active iterators | expand

Commit Message

Patrick Steinhardt Aug. 19, 2024, 3:39 p.m. UTC
Rename the `reftable_new_reader()` function to `reftable_reader_new()`
to match our coding guidelines.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 reftable/reader.c                | 4 ++--
 reftable/reader.h                | 2 +-
 reftable/readwrite_test.c        | 6 +++---
 reftable/reftable-reader.h       | 4 ++--
 reftable/stack.c                 | 4 ++--
 t/helper/test-reftable.c         | 2 +-
 t/unit-tests/t-reftable-merged.c | 6 +++---
 7 files changed, 14 insertions(+), 14 deletions(-)

Comments

Justin Tobler Aug. 22, 2024, 6:51 p.m. UTC | #1
On 24/08/19 05:39PM, Patrick Steinhardt wrote:
> Rename the `reftable_new_reader()` function to `reftable_reader_new()`
> to match our coding guidelines.
> 
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
[snip]  
> -int init_reader(struct reftable_reader *r, struct reftable_block_source *source,
> +int reader_init(struct reftable_reader *r, struct reftable_block_source *source,
>  		const char *name);

Here we also rename `init_reader()` to `reader_init()`, but do not
update its call sites resulting in build errors. Since we remove this in
the next patch anyway, let's drop this change.

-Justin
Junio C Hamano Aug. 22, 2024, 7:09 p.m. UTC | #2
Justin Tobler <jltobler@gmail.com> writes:

> On 24/08/19 05:39PM, Patrick Steinhardt wrote:
>> Rename the `reftable_new_reader()` function to `reftable_reader_new()`
>> to match our coding guidelines.
>> 
>> Signed-off-by: Patrick Steinhardt <ps@pks.im>
>> ---
> [snip]  
>> -int init_reader(struct reftable_reader *r, struct reftable_block_source *source,
>> +int reader_init(struct reftable_reader *r, struct reftable_block_source *source,
>>  		const char *name);
>
> Here we also rename `init_reader()` to `reader_init()`, but do not
> update its call sites resulting in build errors. Since we remove this in
> the next patch anyway, let's drop this change.

True.  The actual definition of the function is also left
unmodified.  Let me locally edit the hunk out.  As you pointed out,
the next step does mention the "new" name in order to remove it, so
there needs a cascading adjustment there, but the fallout is fairly
small (see the attached range-diff).

Thanks.

 1:  348438a69e =  1:  348438a69e reftable/blocksource: drop malloc block source
 2:  ed8bb0e345 =  2:  ed8bb0e345 reftable/stack: inline `stack_compact_range_stats()`
 3:  80cf24d54f !  3:  6b5466771c reftable/reader: rename `reftable_new_reader()`
    @@ reftable/reader.c: int reftable_reader_print_blocks(const char *tablename)
      		goto done;
      
     
    - ## reftable/reader.h ##
    -@@ reftable/reader.h: struct reftable_reader {
    - 	struct reftable_reader_offsets log_offsets;
    - };
    - 
    --int init_reader(struct reftable_reader *r, struct reftable_block_source *source,
    -+int reader_init(struct reftable_reader *r, struct reftable_block_source *source,
    - 		const char *name);
    - void reader_close(struct reftable_reader *r);
    - const char *reader_name(struct reftable_reader *r);
    -
      ## reftable/readwrite_test.c ##
     @@ reftable/readwrite_test.c: static void test_write_empty_table(void)
      
 4:  ce93c128f5 !  4:  bc1eeb32ef reftable/reader: inline `init_reader()`
    @@ reftable/reader.h: struct reftable_reader {
      	struct reftable_reader_offsets log_offsets;
      };
      
    --int reader_init(struct reftable_reader *r, struct reftable_block_source *source,
    +-int init_reader(struct reftable_reader *r, struct reftable_block_source *source,
     -		const char *name);
      void reader_close(struct reftable_reader *r);
      const char *reader_name(struct reftable_reader *r);
 5:  079a3d365e =  5:  3e244b036a reftable/reader: inline `reader_close()`
 6:  7e951256c6 =  6:  41c537e44b reftable/stack: fix broken refnames in `write_n_ref_tables()`
 7:  8e99330cff =  7:  b7596c4c32 reftable/reader: introduce refcounting
 8:  2383c196a6 =  8:  9f28628ecc reftable/reader: keep readers alive during iteration
 9:  8af7c4485f =  9:  51df76889c reftable/stack: reorder swapping in the reloaded stack contents
10:  1ccdac05ab = 10:  32bbcc46b9 reftable/stack: fix segfault when reload with reused readers fails
Patrick Steinhardt Aug. 23, 2024, 5:22 a.m. UTC | #3
On Thu, Aug 22, 2024 at 12:09:33PM -0700, Junio C Hamano wrote:
> Justin Tobler <jltobler@gmail.com> writes:
> 
> > On 24/08/19 05:39PM, Patrick Steinhardt wrote:
> >> Rename the `reftable_new_reader()` function to `reftable_reader_new()`
> >> to match our coding guidelines.
> >> 
> >> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> >> ---
> > [snip]  
> >> -int init_reader(struct reftable_reader *r, struct reftable_block_source *source,
> >> +int reader_init(struct reftable_reader *r, struct reftable_block_source *source,
> >>  		const char *name);
> >
> > Here we also rename `init_reader()` to `reader_init()`, but do not
> > update its call sites resulting in build errors. Since we remove this in
> > the next patch anyway, let's drop this change.

Well spotted! I originally wanted to fix that function's name, too. But
then I realized it's not even needed in the first place.

> True.  The actual definition of the function is also left
> unmodified.  Let me locally edit the hunk out.  As you pointed out,
> the next step does mention the "new" name in order to remove it, so
> there needs a cascading adjustment there, but the fallout is fairly
> small (see the attached range-diff).

Thanks. The range diff looks as expected to me.

Patrick
diff mbox series

Patch

diff --git a/reftable/reader.c b/reftable/reader.c
index 082cf00b60..ea4fdea90b 100644
--- a/reftable/reader.c
+++ b/reftable/reader.c
@@ -637,7 +637,7 @@  void reader_close(struct reftable_reader *r)
 	FREE_AND_NULL(r->name);
 }
 
-int reftable_new_reader(struct reftable_reader **p,
+int reftable_reader_new(struct reftable_reader **p,
 			struct reftable_block_source *src, char const *name)
 {
 	struct reftable_reader *rd = reftable_calloc(1, sizeof(*rd));
@@ -786,7 +786,7 @@  int reftable_reader_print_blocks(const char *tablename)
 	if (err < 0)
 		goto done;
 
-	err = reftable_new_reader(&r, &src, tablename);
+	err = reftable_reader_new(&r, &src, tablename);
 	if (err < 0)
 		goto done;
 
diff --git a/reftable/reader.h b/reftable/reader.h
index a2c204d523..d8cbfd6404 100644
--- a/reftable/reader.h
+++ b/reftable/reader.h
@@ -52,7 +52,7 @@  struct reftable_reader {
 	struct reftable_reader_offsets log_offsets;
 };
 
-int init_reader(struct reftable_reader *r, struct reftable_block_source *source,
+int reader_init(struct reftable_reader *r, struct reftable_block_source *source,
 		const char *name);
 void reader_close(struct reftable_reader *r);
 const char *reader_name(struct reftable_reader *r);
diff --git a/reftable/readwrite_test.c b/reftable/readwrite_test.c
index f411abfe9c..101cdb5cd6 100644
--- a/reftable/readwrite_test.c
+++ b/reftable/readwrite_test.c
@@ -646,7 +646,7 @@  static void test_write_empty_table(void)
 
 	block_source_from_strbuf(&source, &buf);
 
-	err = reftable_new_reader(&rd, &source, "filename");
+	err = reftable_reader_new(&rd, &source, "filename");
 	EXPECT_ERR(err);
 
 	reftable_reader_init_ref_iterator(rd, &it);
@@ -850,7 +850,7 @@  static void test_write_multiple_indices(void)
 	EXPECT(stats->log_stats.index_offset > 0);
 
 	block_source_from_strbuf(&source, &writer_buf);
-	err = reftable_new_reader(&reader, &source, "filename");
+	err = reftable_reader_new(&reader, &source, "filename");
 	EXPECT_ERR(err);
 
 	/*
@@ -907,7 +907,7 @@  static void test_write_multi_level_index(void)
 	EXPECT(stats->ref_stats.max_index_level == 2);
 
 	block_source_from_strbuf(&source, &writer_buf);
-	err = reftable_new_reader(&reader, &source, "filename");
+	err = reftable_reader_new(&reader, &source, "filename");
 	EXPECT_ERR(err);
 
 	/*
diff --git a/reftable/reftable-reader.h b/reftable/reftable-reader.h
index 69621c5b0f..8a05c84685 100644
--- a/reftable/reftable-reader.h
+++ b/reftable/reftable-reader.h
@@ -23,14 +23,14 @@ 
 /* The reader struct is a handle to an open reftable file. */
 struct reftable_reader;
 
-/* reftable_new_reader opens a reftable for reading. If successful,
+/* reftable_reader_new opens a reftable for reading. If successful,
  * returns 0 code and sets pp. The name is used for creating a
  * stack. Typically, it is the basename of the file. The block source
  * `src` is owned by the reader, and is closed on calling
  * reftable_reader_destroy(). On error, the block source `src` is
  * closed as well.
  */
-int reftable_new_reader(struct reftable_reader **pp,
+int reftable_reader_new(struct reftable_reader **pp,
 			struct reftable_block_source *src, const char *name);
 
 /* Initialize a reftable iterator for reading refs. */
diff --git a/reftable/stack.c b/reftable/stack.c
index 891ea971b7..c72435b059 100644
--- a/reftable/stack.c
+++ b/reftable/stack.c
@@ -258,7 +258,7 @@  static int reftable_stack_reload_once(struct reftable_stack *st,
 			if (err < 0)
 				goto done;
 
-			err = reftable_new_reader(&rd, &src, name);
+			err = reftable_reader_new(&rd, &src, name);
 			if (err < 0)
 				goto done;
 		}
@@ -1532,7 +1532,7 @@  static void remove_maybe_stale_table(struct reftable_stack *st, uint64_t max,
 	if (err < 0)
 		goto done;
 
-	err = reftable_new_reader(&rd, &src, name);
+	err = reftable_reader_new(&rd, &src, name);
 	if (err < 0)
 		goto done;
 
diff --git a/t/helper/test-reftable.c b/t/helper/test-reftable.c
index c1942156b5..87c2f42aae 100644
--- a/t/helper/test-reftable.c
+++ b/t/helper/test-reftable.c
@@ -139,7 +139,7 @@  static int dump_reftable(const char *tablename)
 	if (err < 0)
 		goto done;
 
-	err = reftable_new_reader(&r, &src, tablename);
+	err = reftable_reader_new(&r, &src, tablename);
 	if (err < 0)
 		goto done;
 
diff --git a/t/unit-tests/t-reftable-merged.c b/t/unit-tests/t-reftable-merged.c
index 93345c6c8b..8f51aca1b6 100644
--- a/t/unit-tests/t-reftable-merged.c
+++ b/t/unit-tests/t-reftable-merged.c
@@ -102,7 +102,7 @@  merged_table_from_records(struct reftable_ref_record **refs,
 		write_test_table(&buf[i], refs[i], sizes[i]);
 		block_source_from_strbuf(&(*source)[i], &buf[i]);
 
-		err = reftable_new_reader(&(*readers)[i], &(*source)[i],
+		err = reftable_reader_new(&(*readers)[i], &(*source)[i],
 					  "name");
 		check(!err);
 	}
@@ -277,7 +277,7 @@  merged_table_from_log_records(struct reftable_log_record **logs,
 		write_test_log_table(&buf[i], logs[i], sizes[i], i + 1);
 		block_source_from_strbuf(&(*source)[i], &buf[i]);
 
-		err = reftable_new_reader(&(*readers)[i], &(*source)[i],
+		err = reftable_reader_new(&(*readers)[i], &(*source)[i],
 					  "name");
 		check(!err);
 	}
@@ -426,7 +426,7 @@  static void t_default_write_opts(void)
 
 	block_source_from_strbuf(&source, &buf);
 
-	err = reftable_new_reader(&rd, &source, "filename");
+	err = reftable_reader_new(&rd, &source, "filename");
 	check(!err);
 
 	hash_id = reftable_reader_hash_id(rd);