git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Newcomer PATCH] log-tree.c: Supress Wsign-compare-warning
@ 2025-05-21 20:24 Fernando
  2025-05-21 21:08 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Fernando @ 2025-05-21 20:24 UTC (permalink / raw)
  To: git; +Cc: fernandolimabusiness, gitster, adlternative, avarab, stolee, peff

From: Fernando Gouveia Lima <fernandolimabusiness@gmail.com>

Two comparisions between int and size_t, and int and unsigned long int
cause warning sign compare to fire.

Avoid this by changing the type of variable "i" in add_ref_decoration() to unsigned long int and
casting the variable "filename->len" to int in fmt_output_subject().

Signed-off-by: Fernando Gouveia Lima <fernandolimabusiness@gmail.com>
---
This is my first contribution and i got this idea on the Microproject
page. I hope this is the first of many contributions to the git
community :).

 log-tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/log-tree.c b/log-tree.c
index 1d05dc1c70..e0848fcccc 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -151,7 +151,7 @@ static int add_ref_decoration(const char *refname, const char *referent UNUSED,
 			      int flags UNUSED,
 			      void *cb_data)
 {
-	int i;
+	long unsigned int i;
 	struct object *obj;
 	enum object_type objtype;
 	enum decoration_type deco_type = DECORATION_NONE;
@@ -458,7 +458,7 @@ void fmt_output_subject(struct strbuf *filename,
 	}
 	strbuf_addf(filename, "%04d-%s", nr, subject);
 
-	if (max_len < filename->len)
+	if (max_len < (int) filename->len)
 		strbuf_setlen(filename, max_len);
 	strbuf_addstr(filename, suffix);
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-05-30  8:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-21 20:24 [Newcomer PATCH] log-tree.c: Supress Wsign-compare-warning Fernando
2025-05-21 21:08 ` Junio C Hamano
2025-05-23 15:12   ` Patrick Steinhardt
2025-05-23 15:25     ` Taylor Blau
2025-05-23 16:54     ` Junio C Hamano
2025-05-30  8:13       ` Patrick Steinhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).