git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fernando Gouveia Lima fernandolimabusiness@gmail.com
To: git@vger.kernel.org
Cc: fernandolimabusiness@gmail.com, gitster@pobox.com,
	adlternative@gmail.com, avarab@gmail.com, stolee@gmail.com,
	peff@peff.net
Subject: [Newcomer PATCH] log-tree.c: Supress Wsign-compare-warning
Date: Wed, 21 May 2025 17:24:09 -0300	[thread overview]
Message-ID: <20250521202409.26879-1-fernandolimabusiness@gmail.com> (raw)

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


             reply	other threads:[~2025-05-21 20:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-21 20:24 Fernando [this message]
2025-05-21 21:08 ` [Newcomer PATCH] log-tree.c: Supress Wsign-compare-warning 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

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=20250521202409.26879-1-fernandolimabusiness@gmail.com \
    --to=git@vger.kernel.org \
    --cc=adlternative@gmail.com \
    --cc=avarab@gmail.com \
    --cc=fernandolimabusiness@gmail.com \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=stolee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).