git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 01/13] reftable/block: use `size_t` to track restart point index

From
Patrick Steinhardt <ps@pks.im>
Date
May 13, 2024, 08:47 UTC
Message-ID
<ca86a8b58dd074287dd2dd352610ffe46e1605b9.1715589670.git.ps@pks.im>
In-Reply-To
<cover.1715589670.git.ps@pks.im>

The function `block_reader_restart_offset()` gets the offset of the `i`th restart point. `i` is a signed integer though, which is certainly not the correct type to track indices like this. Furthermore, both callers end up passing a `size_t`.

Refactor the code to use a `size_t` instead.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 reftable/block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/reftable/block.c b/reftable/block.c
index 5942cb4053..00030eee06 100644
--- a/reftable/block.c
+++ b/reftable/block.c
@@ -326,9 +326,9 @@ int block_reader_first_key(const struct block_reader *br, struct strbuf *key)
 	return 0;
 }
 
-static uint32_t block_reader_restart_offset(const struct block_reader *br, int i)
+static uint32_t block_reader_restart_offset(const struct block_reader *br, size_t idx)
 {
-	return get_be24(br->restart_bytes + 3 * i);
+	return get_be24(br->restart_bytes + 3 * idx);
 }
 
 void block_iter_seek_start(struct block_iter *it, const struct block_reader *br)
-- 
2.45.GIT
Previous: Patrick SteinhardtNext: Karthik Nayak
Message 30 of 50 in “reftable: prepare for re-seekable iterators”
  1. 00/13 reftable: prepare for re-seekable iteratorsPatrick Steinhardt, May 8, 2024
  2. 01/13 reftable/block: use `size_t` to track restart point indexPatrick Steinhardt, May 8, 2024
  3. 02/13 reftable/reader: avoid copying index iteratorPatrick Steinhardt, May 8, 2024
  4. 03/13 reftable/reader: unify indexed and linear seekingPatrick Steinhardt, May 8, 2024
  5. 04/13 reftable/reader: separate concerns of table iter and reftable readerPatrick Steinhardt, May 8, 2024
  6. 05/13 reftable/reader: inline `reader_seek_internal()`Patrick Steinhardt, May 8, 2024
  7. 06/13 reftable/reader: set up the reader when initializing table iteratorPatrick Steinhardt, May 8, 2024
  8. 07/13 reftable/merged: split up initialization and seeking of recordsPatrick Steinhardt, May 8, 2024
  9. Justin ToblerMay 10, 2024
  10. Patrick SteinhardtMay 13, 2024
  11. 08/13 reftable/merged: simplify indices for subiteratorsPatrick Steinhardt, May 8, 2024
  12. Justin ToblerMay 10, 2024
  13. Patrick SteinhardtMay 13, 2024
  14. 09/13 reftable/generic: move seeking of records into the iteratorPatrick Steinhardt, May 8, 2024
  15. Justin ToblerMay 10, 2024
  16. Patrick SteinhardtMay 13, 2024
  17. 10/13 reftable/generic: adapt interface to allow reuse of iteratorsPatrick Steinhardt, May 8, 2024
  18. 11/13 reftable/reader: adapt interface to allow reuse of iteratorsPatrick Steinhardt, May 8, 2024
  19. Justin ToblerMay 10, 2024
  20. Patrick SteinhardtMay 13, 2024
  21. 12/13 reftable/stack: provide convenience functions to create iteratorsPatrick Steinhardt, May 8, 2024
  22. 13/13 reftable/merged: adapt interface to allow reuse of iteratorsPatrick Steinhardt, May 8, 2024
  23. Junio C HamanoMay 8, 2024
  24. Junio C HamanoMay 9, 2024
  25. Patrick SteinhardtMay 10, 2024
  26. Junio C HamanoMay 10, 2024
  27. Patrick SteinhardtMay 10, 2024
  28. Junio C HamanoMay 10, 2024
  29. 00/13 reftable: prepare for re-seekable iteratorsPatrick Steinhardt, May 13, 2024
  30. 01/13 reftable/block: use `size_t` to track restart point indexPatrick Steinhardt, May 13, 2024
  31. Karthik NayakMay 21, 2024
  32. Patrick SteinhardtMay 22, 2024
  33. 02/13 reftable/reader: avoid copying index iteratorPatrick Steinhardt, May 13, 2024
  34. 03/13 reftable/reader: unify indexed and linear seekingPatrick Steinhardt, May 13, 2024
  35. Karthik NayakMay 21, 2024
  36. Patrick SteinhardtMay 22, 2024
  37. Karthik NayakMay 22, 2024
  38. 04/13 reftable/reader: separate concerns of table iter and reftable readerPatrick Steinhardt, May 13, 2024
  39. 05/13 reftable/reader: inline `reader_seek_internal()`Patrick Steinhardt, May 13, 2024
  40. 06/13 reftable/reader: set up the reader when initializing table iteratorPatrick Steinhardt, May 13, 2024
  41. 07/13 reftable/merged: split up initialization and seeking of recordsPatrick Steinhardt, May 13, 2024
  42. 08/13 reftable/merged: simplify indices for subiteratorsPatrick Steinhardt, May 13, 2024
  43. 09/13 reftable/generic: move seeking of records into the iteratorPatrick Steinhardt, May 13, 2024
  44. 10/13 reftable/generic: adapt interface to allow reuse of iteratorsPatrick Steinhardt, May 13, 2024
  45. 11/13 reftable/reader: adapt interface to allow reuse of iteratorsPatrick Steinhardt, May 13, 2024
  46. 12/13 reftable/stack: provide convenience functions to create iteratorsPatrick Steinhardt, May 13, 2024
  47. 13/13 reftable/merged: adapt interface to allow reuse of iteratorsPatrick Steinhardt, May 13, 2024
  48. Justin ToblerMay 15, 2024
  49. Karthik NayakMay 21, 2024
  50. Patrick SteinhardtMay 22, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.