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

[PATCH v2 01/18] cleanup: rename variables that collide with Rust primitive type names

From
Ezekiel Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Sep 17, 2025, 01:16 UTC
Message-ID
<5f77f1bd5d986dc1f8d123919af24dd219e323e8.1758071798.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2043.v2.git.git.1758071798.gitgitgadget@gmail.com>
From: Ezekiel Newren <ezekielnewren@gmail.com>

Use a regex to find and rename variables that collide with Rust primitive integer and float type names:

    git grep -n -E -e '\<([ui](8|16|32|64|size)|(f(32|64)))\>'
Matches were reviewed and renamed. The remaining matches don't count
because:
- Rust source files:
  contrib/libgit-rs/src/config.rs
  contrib/libgit-sys/src/lib.rs
  t/t4018/rust-impl
  t/t4018/rust-trait
- Intentional references:
  t/helper/test-parse-options.c (prints Rust int names)
  t/t0040-parse-options.sh (tests the above)
View with --color-words to highlight the variable renames.
Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com>
---
 odb.c                         |  8 ++++----
 reftable/record.c             |  6 +++---
 t/helper/test-parse-options.c | 12 ++++++------
 xdiff/xtypes.h                |  2 +-
 xdiff/xutils.c                |  8 ++++----
 xdiff/xutils.h                |  2 +-
 6 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/odb.c b/odb.c
index 2a92a018c4..f0255b4b36 100644
--- a/odb.c
+++ b/odb.c
@@ -913,7 +913,7 @@ void *odb_read_object_peeled(struct object_database *odb,
 {
 	enum object_type type;
 	void *buffer;
-	unsigned long isize;
+	unsigned long isize_;
 	struct object_id actual_oid;
 
 	oidcpy(&actual_oid, oid);
@@ -921,11 +921,11 @@ void *odb_read_object_peeled(struct object_database *odb,
 		int ref_length = -1;
 		const char *ref_type = NULL;
 
-		buffer = odb_read_object(odb, &actual_oid, &type, &isize);
+		buffer = odb_read_object(odb, &actual_oid, &type, &isize_);
 		if (!buffer)
 			return NULL;
 		if (type == required_type) {
-			*size = isize;
+			*size = isize_;
 			if (actual_oid_return)
 				oidcpy(actual_oid_return, &actual_oid);
 			return buffer;
@@ -941,7 +941,7 @@ void *odb_read_object_peeled(struct object_database *odb,
 		}
 		ref_length = strlen(ref_type);
 
-		if (ref_length + odb->repo->hash_algo->hexsz > isize ||
+		if (ref_length + odb->repo->hash_algo->hexsz > isize_ ||
 		    memcmp(buffer, ref_type, ref_length) ||
 		    get_oid_hex_algop((char *) buffer + ref_length, &actual_oid,
 				      odb->repo->hash_algo)) {
diff --git a/reftable/record.c b/reftable/record.c
index fcd387ba5d..e8fc854561 100644
--- a/reftable/record.c
+++ b/reftable/record.c
@@ -675,7 +675,7 @@ static int reftable_log_record_key(const void *r, struct reftable_buf *dest)
 	const struct reftable_log_record *rec =
 		(const struct reftable_log_record *)r;
 	int len = strlen(rec->refname), err;
-	uint8_t i64[8];
+	uint8_t i64_[8];
 	uint64_t ts = 0;
 
 	reftable_buf_reset(dest);
@@ -684,9 +684,9 @@ static int reftable_log_record_key(const void *r, struct reftable_buf *dest)
 		return err;
 
 	ts = (~ts) - rec->update_index;
-	reftable_put_be64(&i64[0], ts);
+	reftable_put_be64(&i64_[0], ts);
 
-	err = reftable_buf_add(dest, i64, sizeof(i64));
+	err = reftable_buf_add(dest, i64_, sizeof(i64_));
 	if (err < 0)
 		return err;
 
diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c
index 68579d83f3..aa1cb693a2 100644
--- a/t/helper/test-parse-options.c
+++ b/t/helper/test-parse-options.c
@@ -120,8 +120,8 @@ int cmd__parse_options(int argc, const char **argv)
 	};
 	struct string_list expect = STRING_LIST_INIT_NODUP;
 	struct string_list list = STRING_LIST_INIT_NODUP;
-	uint16_t u16 = 0;
-	int16_t i16 = 0;
+	uint16_t u16_ = 0;
+	int16_t i16_ = 0;
 
 	struct option options[] = {
 		OPT_BOOL(0, "yes", &boolean, "get a boolean"),
@@ -142,10 +142,10 @@ int cmd__parse_options(int argc, const char **argv)
 		OPT_NEGBIT(0, "neg-or4", &boolean, "same as --no-or4", 4),
 		OPT_GROUP(""),
 		OPT_INTEGER('i', "integer", &integer, "get a integer"),
-		OPT_INTEGER(0, "i16", &i16, "get a 16 bit integer"),
+		OPT_INTEGER(0, "i16", &i16_, "get a 16 bit integer"),
 		OPT_INTEGER('j', NULL, &integer, "get a integer, too"),
 		OPT_UNSIGNED('u', "unsigned", &unsigned_integer, "get an unsigned integer"),
-		OPT_UNSIGNED(0, "u16", &u16, "get a 16 bit unsigned integer"),
+		OPT_UNSIGNED(0, "u16", &u16_, "get a 16 bit unsigned integer"),
 		OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23),
 		OPT_CMDMODE(0, "mode1", &integer, "set integer to 1 (cmdmode option)", 1),
 		OPT_CMDMODE(0, "mode2", &integer, "set integer to 2 (cmdmode option)", 2),
@@ -225,9 +225,9 @@ int cmd__parse_options(int argc, const char **argv)
 	}
 	show(&expect, &ret, "boolean: %d", boolean);
 	show(&expect, &ret, "integer: %d", integer);
-	show(&expect, &ret, "i16: %"PRIdMAX, (intmax_t) i16);
+	show(&expect, &ret, "i16: %"PRIdMAX, (intmax_t) i16_);
 	show(&expect, &ret, "unsigned: %lu", unsigned_integer);
-	show(&expect, &ret, "u16: %"PRIuMAX, (uintmax_t) u16);
+	show(&expect, &ret, "u16: %"PRIuMAX, (uintmax_t) u16_);
 	show(&expect, &ret, "timestamp: %"PRItime, timestamp);
 	show(&expect, &ret, "string: %s", string ? string : "(not set)");
 	show(&expect, &ret, "abbrev: %d", abbrev);
diff --git a/xdiff/xtypes.h b/xdiff/xtypes.h
index 8442bd436e..ec1dc7548a 100644
--- a/xdiff/xtypes.h
+++ b/xdiff/xtypes.h
@@ -32,7 +32,7 @@ typedef struct s_chanode {
 
 typedef struct s_chastore {
 	chanode_t *head, *tail;
-	long isize, nsize;
+	long isize_, nsize;
 	chanode_t *ancur;
 	chanode_t *sncur;
 	long scurr;
diff --git a/xdiff/xutils.c b/xdiff/xutils.c
index 444a108f87..20dee53dbd 100644
--- a/xdiff/xutils.c
+++ b/xdiff/xutils.c
@@ -71,11 +71,11 @@ long xdl_mmfile_size(mmfile_t *mmf)
 }
 
 
-int xdl_cha_init(chastore_t *cha, long isize, long icount) {
+int xdl_cha_init(chastore_t *cha, long isize_, long icount) {
 
 	cha->head = cha->tail = NULL;
-	cha->isize = isize;
-	cha->nsize = icount * isize;
+	cha->isize_ = isize_;
+	cha->nsize = icount * isize_;
 	cha->ancur = cha->sncur = NULL;
 	cha->scurr = 0;
 
@@ -113,7 +113,7 @@ void *xdl_cha_alloc(chastore_t *cha) {
 	}
 
 	data = (char *) ancur + sizeof(chanode_t) + ancur->icurr;
-	ancur->icurr += cha->isize;
+	ancur->icurr += cha->isize_;
 
 	return data;
 }
diff --git a/xdiff/xutils.h b/xdiff/xutils.h
index fd0bba94e8..b531d2ebff 100644
--- a/xdiff/xutils.h
+++ b/xdiff/xutils.h
@@ -28,7 +28,7 @@
 long xdl_bogosqrt(long n);
 int xdl_emit_diffrec(char const *rec, long size, char const *pre, long psize,
 		     xdemitcb_t *ecb);
-int xdl_cha_init(chastore_t *cha, long isize, long icount);
+int xdl_cha_init(chastore_t *cha, long isize_, long icount);
 void xdl_cha_free(chastore_t *cha);
 void *xdl_cha_alloc(chastore_t *cha);
 long xdl_guess_lines(mmfile_t *mf, long sample);
-- 
gitgitgadget
Previous: Ezekiel Newren via GitGitGadgetNext: Eric Sunshine
Message 23 of 100 in “Introduce rust: In xdiff”
  1. 00/15 Introduce rust: In xdiffEzekiel Newren via GitGitGadget, Aug 29, 2025
  2. 01/15 doc: add a policy for using Rustbrian m. carlson via GitGitGadget, Aug 29, 2025
  3. brian m. carlsonAug 29, 2025
  4. Ezekiel NewrenAug 29, 2025
  5. brian m. carlsonSep 2, 2025
  6. Ezekiel NewrenSep 2, 2025
  7. Ezekiel NewrenSep 4, 2025
  8. 02/15 xdiff: introduce rustEzekiel Newren via GitGitGadget, Aug 29, 2025
  9. 03/15 github workflows: install rustEzekiel Newren via GitGitGadget, Aug 29, 2025
  10. 04/15 win+Meson: do allow linking with the Rust-built xdiffJohannes Schindelin via GitGitGadget, Aug 29, 2025
  11. 05/15 github workflows: upload Cargo.lockEzekiel Newren via GitGitGadget, Aug 29, 2025
  12. 06/15 ivec: create a vector type that is interoperable between C and RustEzekiel Newren via GitGitGadget, Aug 29, 2025
  13. 07/15 xdiff/xprepare: remove superfluous forward declarationsEzekiel Newren via GitGitGadget, Aug 29, 2025
  14. 08/15 xdiff: delete unnecessary fields from xrecord_t and xdfile_tEzekiel Newren via GitGitGadget, Aug 29, 2025
  15. 09/15 xdiff: make fields of xrecord_t Rust friendlyEzekiel Newren via GitGitGadget, Aug 29, 2025
  16. 10/15 xdiff: use one definition for freeing xdfile_tEzekiel Newren via GitGitGadget, Aug 29, 2025
  17. 11/15 xdiff: replace chastore with an ivec in xdfile_tEzekiel Newren via GitGitGadget, Aug 29, 2025
  18. 12/15 xdiff: delete nrec field from xdfile_tEzekiel Newren via GitGitGadget, Aug 29, 2025
  19. 13/15 xdiff: delete recs field from xdfile_tEzekiel Newren via GitGitGadget, Aug 29, 2025
  20. 14/15 xdiff: make xdfile_t more rust friendlyEzekiel Newren via GitGitGadget, Aug 29, 2025
  21. 15/15 xdiff: implement xdl_trim_ends() in RustEzekiel Newren via GitGitGadget, Aug 29, 2025
  22. 00/18 Introduce rust: In xdiffEzekiel Newren via GitGitGadget, Sep 17, 2025
  23. 01/18 cleanup: rename variables that collide with Rust primitive type namesEzekiel Newren via GitGitGadget, Sep 17, 2025
  24. Eric SunshineSep 17, 2025
  25. Junio C HamanoSep 17, 2025
  26. Ezekiel NewrenSep 19, 2025
  27. 02/18 make: add -fPIE flagEzekiel Newren via GitGitGadget, Sep 17, 2025
  28. Eric SunshineSep 17, 2025
  29. Ezekiel NewrenSep 19, 2025
  30. Junio C HamanoSep 19, 2025
  31. Ezekiel NewrenSep 19, 2025
  32. Junio C HamanoSep 19, 2025
  33. Collin FunkSep 19, 2025
  34. Junio C HamanoSep 20, 2025
  35. Ramsay JonesSep 21, 2025
  36. 03/18 make: merge xdiff lib into libgit.aEzekiel Newren via GitGitGadget, Sep 17, 2025
  37. Eric SunshineSep 17, 2025
  38. Ezekiel NewrenSep 19, 2025
  39. 04/18 make: merge reftable lib into libgit.aEzekiel Newren via GitGitGadget, Sep 17, 2025
  40. Eric SunshineSep 17, 2025
  41. Junio C HamanoSep 19, 2025
  42. Ezekiel NewrenSep 19, 2025
  43. Junio C HamanoSep 19, 2025
  44. Ezekiel NewrenSep 19, 2025
  45. 05/18 doc: add a policy for using Rustbrian m. carlson via GitGitGadget, Sep 17, 2025
  46. 06/18 BreakingChanges: announce Rust becoming mandatoryPatrick Steinhardt via GitGitGadget, Sep 17, 2025
  47. 07/18 build: introduce rustEzekiel Newren via GitGitGadget, Sep 17, 2025
  48. Eric SunshineSep 17, 2025
  49. Junio C HamanoSep 17, 2025
  50. Eric SunshineSep 18, 2025
  51. Ezekiel NewrenSep 19, 2025
  52. Eric SunshineSep 19, 2025
  53. Ezekiel NewrenSep 19, 2025
  54. 08/18 help: report on whether or not Rust is enabledPatrick Steinhardt via GitGitGadget, Sep 17, 2025
  55. 09/18 github workflows: install rustEzekiel Newren via GitGitGadget, Sep 17, 2025
  56. Eric SunshineSep 17, 2025
  57. 10/18 win+Meson: do allow linking with the Rust-built xdiffJohannes Schindelin via GitGitGadget, Sep 17, 2025
  58. 11/18 github workflows: upload Cargo.lockEzekiel Newren via GitGitGadget, Sep 17, 2025
  59. 12/18 build: new crate, build-helperEzekiel Newren via GitGitGadget, Sep 17, 2025
  60. Eric SunshineSep 17, 2025
  61. 13/18 build-helper: link against libgit.a and any other required C librariesEzekiel Newren via GitGitGadget, Sep 17, 2025
  62. Eric SunshineSep 17, 2025
  63. D. Ben KnobleSep 17, 2025
  64. Eric SunshineSep 17, 2025
  65. Ezekiel NewrenSep 19, 2025
  66. 14/18 build-helper: cbindgen, let crates generate a header fileEzekiel Newren via GitGitGadget, Sep 17, 2025
  67. Eric SunshineSep 17, 2025
  68. Ezekiel NewrenSep 19, 2025
  69. 15/18 varint: use explicit width for integersPatrick Steinhardt via GitGitGadget, Sep 17, 2025
  70. 16/18 build: new crate, miscEzekiel Newren via GitGitGadget, Sep 17, 2025
  71. Eric SunshineSep 17, 2025
  72. Ezekiel NewrenSep 19, 2025
  73. Eric SunshineSep 19, 2025
  74. Ezekiel NewrenSep 19, 2025
  75. 17/18 misc: use BuildHelperEzekiel Newren via GitGitGadget, Sep 17, 2025
  76. 18/18 misc::varint: reimplement as test balloon for RustPatrick Steinhardt via GitGitGadget, Sep 17, 2025
  77. Patrick SteinhardtSep 17, 2025
  78. Ezekiel NewrenSep 19, 2025
  79. Patrick SteinhardtSep 22, 2025
  80. Ezekiel NewrenSep 22, 2025
  81. Patrick SteinhardtSep 22, 2025
  82. Junio C HamanoSep 22, 2025
  83. Ezekiel NewrenSep 22, 2025
  84. Ezekiel NewrenSep 22, 2025
  85. Junio C HamanoSep 22, 2025
  86. Ezekiel NewrenSep 22, 2025
  87. Junio C HamanoSep 22, 2025
  88. Junio C HamanoSep 22, 2025
  89. Junio C HamanoSep 17, 2025
  90. Junio C HamanoSep 17, 2025
  91. Elijah NewrenSep 17, 2025
  92. Junio C HamanoSep 17, 2025
  93. Patrick SteinhardtSep 22, 2025
  94. Ezekiel NewrenSep 22, 2025
  95. Patrick SteinhardtSep 22, 2025
  96. Ezekiel NewrenSep 22, 2025
  97. Patrick SteinhardtSep 23, 2025
  98. Ezekiel NewrenSep 23, 2025
  99. Ezekiel NewrenSep 23, 2025
  100. Junio C HamanoSep 23, 2025

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.