public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Ezekiel Newren via GitGitGadget" <gitgitgadget@gmail•com>
To: git@vger•kernel.org
Cc: Ezekiel Newren <ezekielnewren@gmail•com>,
	Ezekiel Newren <ezekielnewren@gmail•com>
Subject: [PATCH v2 01/18] cleanup: rename variables that collide with Rust primitive type names
Date: Wed, 17 Sep 2025 01:16:21 +0000	[thread overview]
Message-ID: <5f77f1bd5d986dc1f8d123919af24dd219e323e8.1758071798.git.gitgitgadget@gmail.com> (raw)
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


  reply	other threads:[~2025-09-17  1:16 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-29 19:42 [PATCH 00/15] Introduce rust: In xdiff Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 01/15] doc: add a policy for using Rust brian m. carlson via GitGitGadget
2025-08-29 20:00   ` brian m. carlson
2025-08-29 20:11     ` Ezekiel Newren
2025-09-02 16:39       ` brian m. carlson
2025-09-02 18:39         ` Ezekiel Newren
2025-09-04 22:55           ` Ezekiel Newren
2025-08-29 19:42 ` [PATCH 02/15] xdiff: introduce rust Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 03/15] github workflows: install rust Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 04/15] win+Meson: do allow linking with the Rust-built xdiff Johannes Schindelin via GitGitGadget
2025-08-29 19:42 ` [PATCH 05/15] github workflows: upload Cargo.lock Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 06/15] ivec: create a vector type that is interoperable between C and Rust Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 07/15] xdiff/xprepare: remove superfluous forward declarations Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 08/15] xdiff: delete unnecessary fields from xrecord_t and xdfile_t Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 09/15] xdiff: make fields of xrecord_t Rust friendly Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 10/15] xdiff: use one definition for freeing xdfile_t Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 11/15] xdiff: replace chastore with an ivec in xdfile_t Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 12/15] xdiff: delete nrec field from xdfile_t Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 13/15] xdiff: delete recs " Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 14/15] xdiff: make xdfile_t more rust friendly Ezekiel Newren via GitGitGadget
2025-08-29 19:42 ` [PATCH 15/15] xdiff: implement xdl_trim_ends() in Rust Ezekiel Newren via GitGitGadget
2025-09-17  1:16 ` [PATCH v2 00/18] Introduce rust: In xdiff Ezekiel Newren via GitGitGadget
2025-09-17  1:16   ` Ezekiel Newren via GitGitGadget [this message]
2025-09-17  7:42     ` [PATCH v2 01/18] cleanup: rename variables that collide with Rust primitive type names Eric Sunshine
2025-09-17 14:32       ` Junio C Hamano
2025-09-19 19:36         ` Ezekiel Newren
2025-09-17  1:16   ` [PATCH v2 02/18] make: add -fPIE flag Ezekiel Newren via GitGitGadget
2025-09-17  7:44     ` Eric Sunshine
2025-09-19 19:48       ` Ezekiel Newren
2025-09-19 20:07         ` Junio C Hamano
2025-09-19 21:52           ` Ezekiel Newren
2025-09-19 23:43             ` Junio C Hamano
2025-09-19 23:59               ` Collin Funk
2025-09-20 16:44                 ` Junio C Hamano
2025-09-21  1:14                   ` Ramsay Jones
2025-09-17  1:16   ` [PATCH v2 03/18] make: merge xdiff lib into libgit.a Ezekiel Newren via GitGitGadget
2025-09-17  7:46     ` Eric Sunshine
2025-09-19 19:54       ` Ezekiel Newren
2025-09-17  1:16   ` [PATCH v2 04/18] make: merge reftable " Ezekiel Newren via GitGitGadget
2025-09-17  7:46     ` Eric Sunshine
2025-09-19 19:02     ` Junio C Hamano
2025-09-19 20:00       ` Ezekiel Newren
2025-09-19 20:14         ` Junio C Hamano
2025-09-19 23:02           ` Ezekiel Newren
2025-09-17  1:16   ` [PATCH v2 05/18] doc: add a policy for using Rust brian m. carlson via GitGitGadget
2025-09-17  1:16   ` [PATCH v2 06/18] BreakingChanges: announce Rust becoming mandatory Patrick Steinhardt via GitGitGadget
2025-09-17  1:16   ` [PATCH v2 07/18] build: introduce rust Ezekiel Newren via GitGitGadget
2025-09-17  8:26     ` Eric Sunshine
2025-09-17 14:54       ` Junio C Hamano
2025-09-18  7:06         ` Eric Sunshine
2025-09-19 20:11       ` Ezekiel Newren
2025-09-19 20:24         ` Eric Sunshine
2025-09-19 21:28           ` Ezekiel Newren
2025-09-17  1:16   ` [PATCH v2 08/18] help: report on whether or not Rust is enabled Patrick Steinhardt via GitGitGadget
2025-09-17  1:16   ` [PATCH v2 09/18] github workflows: install rust Ezekiel Newren via GitGitGadget
2025-09-17  8:01     ` Eric Sunshine
2025-09-17  1:16   ` [PATCH v2 10/18] win+Meson: do allow linking with the Rust-built xdiff Johannes Schindelin via GitGitGadget
2025-09-17  1:16   ` [PATCH v2 11/18] github workflows: upload Cargo.lock Ezekiel Newren via GitGitGadget
2025-09-17  1:16   ` [PATCH v2 12/18] build: new crate, build-helper Ezekiel Newren via GitGitGadget
2025-09-17  8:58     ` Eric Sunshine
2025-09-17  1:16   ` [PATCH v2 13/18] build-helper: link against libgit.a and any other required C libraries Ezekiel Newren via GitGitGadget
2025-09-17  8:51     ` Eric Sunshine
2025-09-17 23:07       ` D. Ben Knoble
2025-09-17 23:31         ` Eric Sunshine
2025-09-19 20:25       ` Ezekiel Newren
2025-09-17  1:16   ` [PATCH v2 14/18] build-helper: cbindgen, let crates generate a header file Ezekiel Newren via GitGitGadget
2025-09-17  9:08     ` Eric Sunshine
2025-09-19 20:34       ` Ezekiel Newren
2025-09-17  1:16   ` [PATCH v2 15/18] varint: use explicit width for integers Patrick Steinhardt via GitGitGadget
2025-09-17  1:16   ` [PATCH v2 16/18] build: new crate, misc Ezekiel Newren via GitGitGadget
2025-09-17  9:16     ` Eric Sunshine
2025-09-19 20:42     ` Ezekiel Newren
2025-09-19 20:50       ` Eric Sunshine
2025-09-19 21:54         ` Ezekiel Newren
2025-09-17  1:16   ` [PATCH v2 17/18] misc: use BuildHelper Ezekiel Newren via GitGitGadget
2025-09-17  1:16   ` [PATCH v2 18/18] misc::varint: reimplement as test balloon for Rust Patrick Steinhardt via GitGitGadget
2025-09-17  5:58   ` [PATCH v2 00/18] Introduce rust: In xdiff Patrick Steinhardt
2025-09-19 20:57     ` Ezekiel Newren
2025-09-22 13:01       ` Patrick Steinhardt
2025-09-22 15:31         ` Ezekiel Newren
2025-09-22 16:08           ` Patrick Steinhardt
2025-09-22 16:47           ` Junio C Hamano
2025-09-22 17:23             ` Ezekiel Newren
2025-09-22 17:32               ` Ezekiel Newren
2025-09-22 18:17                 ` Junio C Hamano
2025-09-22 18:33                   ` Ezekiel Newren
2025-09-22 18:41                     ` Junio C Hamano
2025-09-22 18:12               ` Junio C Hamano
2025-09-17 17:07   ` Junio C Hamano
2025-09-17 20:44     ` Junio C Hamano
2025-09-17 21:34     ` Elijah Newren
2025-09-17 22:48       ` Junio C Hamano
2025-09-22 13:01         ` Patrick Steinhardt
2025-09-22 15:18           ` Ezekiel Newren
2025-09-22 16:15             ` Patrick Steinhardt
2025-09-22 16:27               ` Ezekiel Newren
2025-09-23  5:11                 ` Patrick Steinhardt
2025-09-23 16:32                   ` Ezekiel Newren
2025-09-23 18:05   ` Ezekiel Newren
2025-09-23 21:04     ` Junio C Hamano

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=5f77f1bd5d986dc1f8d123919af24dd219e323e8.1758071798.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail$(echo .)com \
    --cc=ezekielnewren@gmail$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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