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

[GSoC PATCH] decorate: fix sign comparison warnings

From
Arnav Bhate <bhatearnav@gmail.com>
Date
Mar 10, 2025, 09:51 UTC
Message-ID
<afa6b428-3190-42ae-9eac-540c95b576fd@gmail.com>

In two instances, an int was initialized and assigned the value of an unsigned int. Then, the int was compared to unsigned ints.

Replace int with unsigned int in both cases.
Signed-off-by: Arnav Bhate <bhatearnav@gmail.com>
---
 decorate.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/decorate.c b/decorate.c
index e161e13772..8d5774fcdd 100644
--- a/decorate.c
+++ b/decorate.c
@@ -3,8 +3,6 @@
  * data.
  */
 
-#define DISABLE_SIGN_COMPARE_WARNINGS
-
 #include "git-compat-util.h"
 #include "object.h"
 #include "decorate.h"
@@ -16,7 +14,7 @@ static unsigned int hash_obj(const struct object *obj, unsigned int n)
 
 static void *insert_decoration(struct decoration *n, const struct object *base, void *decoration)
 {
-	int size = n->size;
+	unsigned int size = n->size;
 	struct decoration_entry *entries = n->entries;
 	unsigned int j = hash_obj(base, size);
 
@@ -59,7 +57,7 @@ static void grow_decoration(struct decoration *n)
 void *add_decoration(struct decoration *n, const struct object *obj,
 		void *decoration)
 {
-	int nr = n->nr + 1;
+	unsigned int nr = n->nr + 1;
 
 	if (nr > n->size * 2 / 3)
 		grow_decoration(n);
-- 
2.48.1
Next: Junio C Hamano
Message 1 of 6 in “decorate: fix sign comparison warnings”
  1. decorate: fix sign comparison warningsArnav Bhate, Mar 10, 2025
  2. Junio C HamanoMar 10, 2025
  3. Arnav BhateMar 10, 2025
  4. decorate: fix sign comparison warningsArnav Bhate, Mar 10, 2025
  5. Karthik NayakMar 10, 2025
  6. Arnav BhateMar 11, 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.