Skip to contentSkip to conversation

git: use signed counters when comparing with signed vars

PATCH Superseded AreaZR via GitGitGadget 1 participant 3 messages Dec 18, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git: use signed counters when comparing with signed vars

From: Seija Kijin <[email protected]>

The compiler (at least LLVM) treats them better anyway because of the C standard not defining signed overflow.

---
git: use signed counters when comparing with signed vars

The compiler (at least LLVM) treats them better anyway because of the C standard not defining signed overflow.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1843%2FAreaZR%2Fone-more-time-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1843/AreaZR/one-more-time-v1
Pull-Request: https://github.com/git/git/pull/1843

 add-interactive.c | 2 +-
 bloom.c           | 2 +-
 git.c             | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
add-interactive.c +1 -1
index 49042b30261..12c23fa10ba 100644
@@ -848,7 +848,7 @@ static int get_untracked_files(struct repository *r,
 			       const struct pathspec *ps)
 {
 	struct dir_struct dir = { 0 };
-	size_t i;
+	int i;
 	struct strbuf buf = STRBUF_INIT;
 
 	if (repo_read_index(r) < 0)
bloom.c +1 -1
index c4286341059..42db509bea9 100644
@@ -314,7 +314,7 @@ static int has_entries_with_high_bit(struct repository *r, struct tree *t)
 
 		init_tree_desc(&desc, &t->object.oid, t->buffer, t->size);
 		while (tree_entry(&desc, &entry)) {
-			size_t i;
+			int i;
 			for (i = 0; i < entry.pathlen; i++) {
 				if (entry.path[i] & 0x80) {
 					t->object.flags |= HIGH_BITS;
git.c +1 -1
index 46b3c740c5d..86f7112f4bf 100644
@@ -946,7 +946,7 @@ int cmd_main(int argc, const char **argv)
 	 */
 	setup_path();
 
-	for (size_t i = 0; i < argc; i++)
+	for (int i = 0; i < argc; i++)
 		strvec_push(&args, argv[i]);
 
 	while (1) {

base-commit: 2ccc89b0c16c51561da90d21cfbb4b58cc877bf6

Signature · 1 line
gitgitgadget
#1 lore raw

PATCH v2 1/1 git: use signed loop counters when comparing with signed vars

From: Seija Kijin <[email protected]>

The compiler (at least LLVM) treats them better anyway because of the C standard not defining signed overflow.

---
git: use signed loop counters when comparing with signed vars

The compiler (at least LLVM) treats them better anyway because of the C standard not defining signed overflow.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1843%2FAreaZR%2Fone-more-time-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1843/AreaZR/one-more-time-v2
Pull-Request: https://github.com/git/git/pull/1843

Range-diff vs v1:

1: 1dea0ce98b4 ! 1: c8552548fe9 git: use signed counters when comparing with signed vars
@@ Metadata
Author: Seija Kijin <[email protected]>

## Commit message ##
- git: use signed counters when comparing with signed vars
+ git: use signed loop counters when comparing with signed vars

The compiler (at least LLVM) treats them better anyway because of the C standard not defining signed overflow.

 add-interactive.c | 2 +-
 bloom.c           | 2 +-
 git.c             | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
add-interactive.c +1 -1
index 49042b30261..12c23fa10ba 100644
@@ -848,7 +848,7 @@ static int get_untracked_files(struct repository *r,
 			       const struct pathspec *ps)
 {
 	struct dir_struct dir = { 0 };
-	size_t i;
+	int i;
 	struct strbuf buf = STRBUF_INIT;
 
 	if (repo_read_index(r) < 0)
bloom.c +1 -1
index c4286341059..42db509bea9 100644
@@ -314,7 +314,7 @@ static int has_entries_with_high_bit(struct repository *r, struct tree *t)
 
 		init_tree_desc(&desc, &t->object.oid, t->buffer, t->size);
 		while (tree_entry(&desc, &entry)) {
-			size_t i;
+			int i;
 			for (i = 0; i < entry.pathlen; i++) {
 				if (entry.path[i] & 0x80) {
 					t->object.flags |= HIGH_BITS;
git.c +1 -1
index 46b3c740c5d..86f7112f4bf 100644
@@ -946,7 +946,7 @@ int cmd_main(int argc, const char **argv)
 	 */
 	setup_path();
 
-	for (size_t i = 0; i < argc; i++)
+	for (int i = 0; i < argc; i++)
 		strvec_push(&args, argv[i]);
 
 	while (1) {

base-commit: 063bcebf0c917140ca0e705cbe0fdea127e90086

Signature · 1 line
gitgitgadget
#2 lore raw

PATCH v3 1/1 git: use signed loop counters when comparing with signed vars

From: Seija Kijin <[email protected]>

The compiler (at least LLVM) treats them better anyway because of the C standard not defining signed overflow.

---
git: use signed loop counters when comparing with signed vars

The compiler (at least LLVM) treats them better anyway because of the C standard not defining signed overflow.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1843%2FAreaZR%2Fone-more-time-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1843/AreaZR/one-more-time-v3
Pull-Request: https://github.com/git/git/pull/1843

Range-diff vs v2:

1: c8552548fe9 = 1: 754e4a60ff6 git: use signed loop counters when comparing with signed vars

 add-interactive.c | 2 +-
 bloom.c           | 2 +-
 git.c             | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
add-interactive.c +1 -1
index 49042b30261..12c23fa10ba 100644
@@ -848,7 +848,7 @@ static int get_untracked_files(struct repository *r,
 			       const struct pathspec *ps)
 {
 	struct dir_struct dir = { 0 };
-	size_t i;
+	int i;
 	struct strbuf buf = STRBUF_INIT;
 
 	if (repo_read_index(r) < 0)
bloom.c +1 -1
index c4286341059..42db509bea9 100644
@@ -314,7 +314,7 @@ static int has_entries_with_high_bit(struct repository *r, struct tree *t)
 
 		init_tree_desc(&desc, &t->object.oid, t->buffer, t->size);
 		while (tree_entry(&desc, &entry)) {
-			size_t i;
+			int i;
 			for (i = 0; i < entry.pathlen; i++) {
 				if (entry.path[i] & 0x80) {
 					t->object.flags |= HIGH_BITS;
git.c +1 -1
index 46b3c740c5d..86f7112f4bf 100644
@@ -946,7 +946,7 @@ int cmd_main(int argc, const char **argv)
 	 */
 	setup_path();
 
-	for (size_t i = 0; i < argc; i++)
+	for (int i = 0; i < argc; i++)
 		strvec_push(&args, argv[i]);
 
 	while (1) {

base-commit: d882f382b3d939d90cfa58d17b17802338f05d66

Signature · 1 line
gitgitgadget